From a1c527f712c0f2ec3a687a84ff0350b47ab12f7c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 23:22:05 +0000 Subject: [PATCH] chore(codegen): update bevy bindings --- .../src/bevy/bevy_core.rs | 82 + .../src/bevy/bevy_ecs.rs | 552 + .../src/bevy/bevy_hierarchy.rs | 151 + .../src/bevy/bevy_input.rs | 1865 ++ .../src/bevy/bevy_math.rs | 4324 +++ .../src/bevy/bevy_reflect.rs | 22843 ++++++++++++++++ .../src/bevy/bevy_time.rs | 602 + .../src/bevy/bevy_transform.rs | 347 + .../src/bevy/mod.rs | 25 + 9 files changed, 30791 insertions(+) create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_core.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_ecs.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_hierarchy.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_input.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_math.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_reflect.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_time.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/bevy_transform.rs create mode 100644 crates/bevy_mod_scripting_functions/src/bevy/mod.rs diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_core.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_core.rs new file mode 100644 index 0000000000..b806e52e0e --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_core.rs @@ -0,0 +1,82 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::core::prelude::Name", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{}", _self) +} +"#] +)] +pub struct Name {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + Ok(()) + } +} +fn bevy_core_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyCoreScriptingPlugin; +impl bevy::app::Plugin for BevyCoreScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_core_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyCoreAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_ecs.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_ecs.rs new file mode 100644 index 0000000000..92f8cdd32c --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_ecs.rs @@ -0,0 +1,552 @@ +// @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::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::entity::Entity", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new entity ID with the specified `index` and a generation of 1. +/// # Note +/// Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor +/// [`Commands::spawn`](crate::system::Commands::spawn). This method should generally +/// only be used for sharing entities across apps, and only when they have a scheme +/// worked out to share an index space (which doesn't happen by default). +/// In general, one should not try to synchronize the ECS by attempting to ensure that +/// `Entity` lines up between instances, but instead insert a secondary identifier as +/// a component. + + #[lua()] + fn from_raw(index: u32) -> Val; + +"#, + r#" +/// Convert to a form convenient for passing outside of rust. +/// Only useful for identifying entities within the same instance of an application. Do not use +/// for serialization between runs. +/// No particular structure is guaranteed for the returned bits. + + #[lua()] + fn to_bits(_self: Val) -> u64; + +"#, + r#" +/// Reconstruct an `Entity` previously destructured with [`Entity::to_bits`]. +/// Only useful when applied to results from `to_bits` in the same instance of an application. +/// # Panics +/// This method will likely panic if given `u64` values that did not come from [`Entity::to_bits`]. + + #[lua()] + fn from_bits(bits: u64) -> Val; + +"#, + r#" +/// Return a transiently unique identifier. +/// No two simultaneously-live entities share the same index, but dead entities' indices may collide +/// with both live and dead entities. Useful for compactly representing entities within a +/// specific snapshot of the world, such as when serializing. + + #[lua()] + fn index(_self: Val) -> u32; + +"#, + r#" +/// Returns the generation of this Entity's index. The generation is incremented each time an +/// entity with a given index is despawned. This serves as a "count" of the number of times a +/// given index has been reused (index, generation) pairs uniquely identify a given Entity. + + #[lua()] + fn generation(_self: Val) -> u32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Entity {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::world::OnAdd", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct OnAdd {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::world::OnInsert", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct OnInsert {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::world::OnRemove", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct OnRemove {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::world::OnReplace", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct OnReplace {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::ComponentId", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Creates a new [`ComponentId`]. +/// The `index` is a unique value associated with each type of component in a given world. +/// Usually, this value is taken from a counter incremented for each type of component registered with the world. + + #[lua()] + fn new(index: usize) -> Val; + +"#, + r#" +/// Returns the index of the current component. + + #[lua()] + fn index(_self: Val) -> usize; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ComponentId(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::Tick", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates a new [`Tick`] wrapping the given value. + + #[lua()] + fn new(tick: u32) -> Val; + +"#, + r#" +/// Gets the value of this change tick. + + #[lua()] + fn get(_self: Val) -> u32; + +"#, + r#" +/// Sets the value of this change tick. + + #[lua()] + fn set(_self: Mut, tick: u32) -> (); + +"#, + r#" +/// Returns `true` if this `Tick` occurred since the system's `last_run`. +/// `this_run` is the current tick of the system, used as a reference to help deal with wraparound. + + #[lua()] + fn is_newer_than( + _self: Val, + last_run: Val, + this_run: Val, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Tick {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::component::ComponentTicks", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Returns `true` if the component or resource was added after the system last ran +/// (or the system is running for the first time). + + #[lua()] + fn is_added( + _self: Ref, + last_run: Val, + this_run: Val, + ) -> bool; + +"#, + r#" +/// 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()] + fn is_changed( + _self: Ref, + last_run: Val, + this_run: Val, + ) -> bool; + +"#, + r#" +/// Creates a new instance with the same change tick for `added` and `changed`. + + #[lua()] + fn new( + change_tick: Val, + ) -> Val; + +"#, + r#" +/// Manually sets the change tick. +/// This is normally done automatically via the [`DerefMut`](std::ops::DerefMut) implementation +/// on [`Mut`](crate::change_detection::Mut), [`ResMut`](crate::change_detection::ResMut), etc. +/// However, components and resources that make use of interior mutability might require manual updates. +/// # Example +/// ```no_run +/// # use bevy_ecs::{world::World, component::ComponentTicks}; +/// let world: World = unimplemented!(); +/// let component_ticks: ComponentTicks = unimplemented!(); +/// component_ticks.set_changed(world.read_change_tick()); +/// ``` + + #[lua()] + fn set_changed( + _self: Mut, + change_tick: Val, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ComponentTicks { + added: bevy::ecs::component::Tick, + changed: bevy::ecs::component::Tick, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::identifier::Identifier", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Returns the value of the low segment of the [`Identifier`]. + + #[lua()] + fn low(_self: Val) -> u32; + +"#, + r#" +/// Returns the masked value of the high segment of the [`Identifier`]. +/// Does not include the flag bits. + + #[lua()] + fn masked_high(_self: Val) -> u32; + +"#, + r#" +/// Convert the [`Identifier`] into a `u64`. + + #[lua()] + fn to_bits(_self: Val) -> 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()] + fn from_bits(value: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Identifier {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::entity::EntityHash", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#] +)] +pub struct EntityHash {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::removal_detection::RemovedComponentEntity", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RemovedComponentEntity(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::ecs::system::SystemIdMarker", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[] +)] +pub struct SystemIdMarker {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance("Entity", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "ComponentId", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Tick", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "ComponentTicks", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Identifier", + crate::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_ecs_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyEcsScriptingPlugin; +impl bevy::app::Plugin for BevyEcsScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_ecs_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyEcsAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_hierarchy.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_hierarchy.rs new file mode 100644 index 0000000000..a0787da0c8 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_hierarchy.rs @@ -0,0 +1,151 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_core::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::hierarchy::prelude::Children", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Swaps the child at `a_index` with the child at `b_index`. + + #[lua()] + fn swap( + _self: Mut, + a_index: usize, + b_index: usize, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Children(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::hierarchy::prelude::Parent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Parent(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::hierarchy::HierarchyEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct HierarchyEvent {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + Ok(()) + } +} +fn bevy_hierarchy_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyHierarchyScriptingPlugin; +impl bevy::app::Plugin for BevyHierarchyScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_hierarchy_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyHierarchyAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_input.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_input.rs new file mode 100644 index 0000000000..405c182eed --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_input.rs @@ -0,0 +1,1865 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_core::*; +use super::bevy_math::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::Gamepad", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Returns the USB vendor ID as assigned by the USB-IF, if available. + + #[lua()] + fn vendor_id(_self: Ref) -> std::option::Option; + +"#, + r#" +/// Returns the USB product ID as assigned by the [vendor], if available. +/// [vendor]: Self::vendor_id + + #[lua()] + fn product_id(_self: Ref) -> std::option::Option; + +"#, + r#" +/// Returns `true` if the [`GamepadButton`] has been pressed. + + #[lua()] + fn pressed( + _self: Ref, + button_type: Val, + ) -> bool; + +"#, + r#" +/// Returns `true` if the [`GamepadButton`] has been pressed during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. + + #[lua()] + fn just_pressed( + _self: Ref, + button_type: Val, + ) -> bool; + +"#, + r#" +/// Returns `true` if the [`GamepadButton`] has been released during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. + + #[lua()] + fn just_released( + _self: Ref, + button_type: Val, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Gamepad {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadAxis", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadAxis {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButton", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButton {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadSettings { + default_button_settings: bevy::input::gamepad::ButtonSettings, + default_axis_settings: bevy::input::gamepad::AxisSettings, + default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, + button_settings: ReflectReference, + axis_settings: ReflectReference, + button_axis_settings: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::KeyCode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct KeyCode {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseButton", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseButton {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::TouchInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchInput { + phase: bevy::input::touch::TouchPhase, + position: ReflectReference, + window: ReflectReference, + force: ReflectReference, + id: u64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::KeyboardFocusLost", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct KeyboardFocusLost {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::KeyboardInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct KeyboardInput { + key_code: bevy::input::keyboard::KeyCode, + logical_key: bevy::input::keyboard::Key, + state: bevy::input::ButtonState, + repeat: bool, + window: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::AccumulatedMouseMotion", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AccumulatedMouseMotion { + delta: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::AccumulatedMouseScroll", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AccumulatedMouseScroll { + unit: bevy::input::mouse::MouseScrollUnit, + delta: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseButtonInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseButtonInput { + button: bevy::input::mouse::MouseButton, + state: bevy::input::ButtonState, + window: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseMotion", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseMotion { + delta: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseWheel", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseWheel { + unit: bevy::input::mouse::MouseScrollUnit, + x: f32, + y: f32, + window: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadAxisChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadAxisChangedEvent { + entity: ReflectReference, + axis: bevy::input::gamepad::GamepadAxis, + value: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButtonChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButtonChangedEvent { + entity: ReflectReference, + button: bevy::input::gamepad::GamepadButton, + state: bevy::input::ButtonState, + value: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadButtonStateChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadButtonStateChangedEvent { + entity: ReflectReference, + button: bevy::input::gamepad::GamepadButton, + state: bevy::input::ButtonState, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadConnection", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadConnection {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadConnectionEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Is the gamepad connected? + + #[lua()] + fn connected(_self: Ref) -> bool; + +"#, + r#" +/// Is the gamepad disconnected? + + #[lua()] + fn disconnected(_self: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadConnectionEvent { + gamepad: ReflectReference, + connection: bevy::input::gamepad::GamepadConnection, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadEvent {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadInput", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadInput {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadRumbleRequest", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#] +)] +pub struct GamepadRumbleRequest {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::RawGamepadAxisChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RawGamepadAxisChangedEvent { + gamepad: ReflectReference, + axis: bevy::input::gamepad::GamepadAxis, + value: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::RawGamepadButtonChangedEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RawGamepadButtonChangedEvent { + gamepad: ReflectReference, + button: bevy::input::gamepad::GamepadButton, + value: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::RawGamepadEvent", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RawGamepadEvent {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gestures::PinchGesture", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct PinchGesture(f32); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gestures::RotationGesture", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RotationGesture(f32); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gestures::DoubleTapGesture", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct DoubleTapGesture {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gestures::PanGesture", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct PanGesture(ReflectReference); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::ButtonState", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Is this button pressed? + + #[lua()] + fn is_pressed(_self: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonState {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::ButtonSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + 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()] + fn is_pressed(_self: Ref, 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()] + fn is_released(_self: Ref, value: f32) -> bool; + +"#, + r#" +/// Get the button input threshold above which the button is considered pressed. + + #[lua()] + fn press_threshold(_self: Ref) -> 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()] + fn set_press_threshold( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +/// Get the button input threshold below which the button is considered released. + + #[lua()] + fn release_threshold(_self: Ref) -> 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()] + fn set_release_threshold( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonSettings {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::AxisSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Get the value above which inputs will be rounded up to 1.0. + + #[lua()] + fn livezone_upperbound(_self: Ref) -> f32; + +"#, + r#" +/// Try to set the value above which inputs will be rounded up to 1.0. +/// If the value passed is negative or less than `deadzone_upperbound`, +/// the value will not be changed. +/// Returns the new value of `livezone_upperbound`. + + #[lua()] + fn set_livezone_upperbound( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +/// Get the value below which positive inputs will be rounded down to 0.0. + + #[lua()] + fn deadzone_upperbound(_self: Ref) -> f32; + +"#, + r#" +/// Try to set the value below which positive inputs will be rounded down to 0.0. +/// If the value passed is negative or greater than `livezone_upperbound`, +/// the value will not be changed. +/// Returns the new value of `deadzone_upperbound`. + + #[lua()] + fn set_deadzone_upperbound( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +/// Get the value below which negative inputs will be rounded down to -1.0. + + #[lua()] + fn livezone_lowerbound(_self: Ref) -> f32; + +"#, + r#" +/// Try to set the value below which negative inputs will be rounded down to -1.0. +/// If the value passed is positive or greater than `deadzone_lowerbound`, +/// the value will not be changed. +/// Returns the new value of `livezone_lowerbound`. + + #[lua()] + fn set_livezone_lowerbound( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +/// Get the value above which inputs will be rounded up to 0.0. + + #[lua()] + fn deadzone_lowerbound(_self: Ref) -> f32; + +"#, + r#" +/// Try to set the value above which inputs will be rounded up to 0.0. +/// If the value passed is less than -1.0 or less than `livezone_lowerbound`, +/// the value will not be changed. +/// Returns the new value of `deadzone_lowerbound`. + + #[lua()] + fn set_deadzone_lowerbound( + _self: Mut, + value: f32, + ) -> f32; + +"#, + r#" +/// Get the minimum value by which input must change before the change is registered. + + #[lua()] + fn threshold(_self: Ref) -> f32; + +"#, + r#" +/// Try to set the minimum value by which input must change before the changes will be applied. +/// If the value passed is not within [0.0..=2.0], the value will not be changed. +/// Returns the new value of threshold. + + #[lua()] + fn set_threshold(_self: Mut, value: f32) -> f32; + +"#, + r#" +/// Clamps the `raw_value` according to the `AxisSettings`. + + #[lua()] + fn clamp(_self: Ref, new_value: f32) -> f32; + +"#, + r#" +/// Filters the `new_value` based on the `old_value`, according to the [`AxisSettings`]. +/// Returns the clamped `new_value` if the change exceeds the settings threshold, +/// and `None` otherwise. + + #[lua()] + fn filter( + _self: Ref, + new_value: f32, + old_value: std::option::Option, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AxisSettings {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::ButtonAxisSettings", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + 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()] + fn filter( + _self: Ref, + new_value: f32, + old_value: std::option::Option, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ButtonAxisSettings { + high: f32, + low: f32, + threshold: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::gamepad::GamepadRumbleIntensity", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new rumble intensity with weak motor intensity set to the given value. +/// Clamped within the `0.0` to `1.0` range. + + #[lua()] + fn weak_motor(intensity: f32) -> Val; + +"#, + r#" +/// Creates a new rumble intensity with strong motor intensity set to the given value. +/// Clamped within the `0.0` to `1.0` range. + + #[lua()] + fn strong_motor(intensity: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GamepadRumbleIntensity { + strong_motor: f32, + weak_motor: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::Key", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Key {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::NativeKeyCode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct NativeKeyCode {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::keyboard::NativeKey", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct NativeKey {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::mouse::MouseScrollUnit", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq( + _self: Ref, + ) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct MouseScrollUnit {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::TouchPhase", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TouchPhase {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::input::touch::ForceTouch", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ForceTouch {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "GamepadRumbleIntensity", + crate::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_input_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyInputScriptingPlugin; +impl bevy::app::Plugin for BevyInputScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_input_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyInputAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_math.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_math.rs new file mode 100644 index 0000000000..b2986ac4de --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_math.rs @@ -0,0 +1,4324 @@ +// @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::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::AspectRatio", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Returns the aspect ratio as a f32 value. + + #[lua()] + fn ratio(_self: Ref) -> f32; + +"#, + r#" +/// Returns the inverse of this aspect ratio (height/width). + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Returns true if the aspect ratio represents a landscape orientation. + + #[lua()] + fn is_landscape(_self: Ref) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio represents a portrait orientation. + + #[lua()] + fn is_portrait(_self: Ref) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio is exactly square. + + #[lua()] + fn is_square(_self: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AspectRatio(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::CompassOctant", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CompassOctant {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::CompassQuadrant", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CompassQuadrant {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Isometry2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Create a two-dimensional isometry from a rotation. + + #[lua()] + fn from_rotation(rotation: Val) -> Val; + +"#, + r#" +/// Create a two-dimensional isometry from a translation with the given `x` and `y` components. + + #[lua()] + fn from_xy(x: f32, y: f32) -> Val; + +"#, + r#" +/// The inverse isometry that undoes this one. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua()] + fn inverse_mul( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Isometry2d { + rotation: bevy::math::Rot2, + translation: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Isometry3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a three-dimensional isometry from a translation with the given `x`, `y`, and `z` components. + + #[lua()] + fn from_xyz(x: f32, y: f32, z: f32) -> Val; + +"#, + r#" +/// The inverse isometry that undoes this one. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua()] + fn inverse_mul( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Isometry3d { + rotation: ReflectReference, + translation: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Ray2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Ray2d { + origin: ReflectReference, + direction: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Ray3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Ray3d { + origin: ReflectReference, + direction: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Rot2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise angle in radians. +/// # Note +/// The input rotation will always be clamped to the range `(-π, π]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// # use std::f32::consts::{FRAC_PI_2, PI}; +/// let rot1 = Rot2::radians(3.0 * FRAC_PI_2); +/// let rot2 = Rot2::radians(-FRAC_PI_2); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::radians(PI); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` + + #[lua()] + fn radians(radians: f32) -> Val; + +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise angle in degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-180°, 180°]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::degrees(270.0); +/// let rot2 = Rot2::degrees(-90.0); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::degrees(180.0); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` + + #[lua()] + fn degrees(degrees: f32) -> Val; + +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise fraction of a full turn of 360 degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-50%, 50%]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::turn_fraction(0.75); +/// let rot2 = Rot2::turn_fraction(-0.25); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::turn_fraction(0.5); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` + + #[lua()] + fn turn_fraction(fraction: f32) -> Val; + +"#, + 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()] + fn from_sin_cos(sin: f32, cos: f32) -> Val; + +"#, + r#" +/// Returns the rotation in radians in the `(-pi, pi]` range. + + #[lua()] + fn as_radians(_self: Val) -> f32; + +"#, + r#" +/// Returns the rotation in degrees in the `(-180, 180]` range. + + #[lua()] + fn as_degrees(_self: Val) -> f32; + +"#, + r#" +/// Returns the rotation as a fraction of a full 360 degree turn. + + #[lua()] + fn as_turn_fraction(_self: Val) -> f32; + +"#, + r#" +/// Returns the sine and cosine of the rotation angle in radians. + + #[lua()] + fn sin_cos(_self: Val) -> (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()] + fn length(_self: Val) -> 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()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / self.length()`. +/// For valid results, `self` must _not_ have a length of zero. + + #[lua()] + fn length_recip(_self: Val) -> 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()] + fn normalize(_self: Val) -> Val; + +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`](crate::Dir3::fast_renormalize) for an example of when such error accumulation might occur. + + #[lua()] + fn fast_renormalize(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if the rotation is neither infinite nor NaN. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if the rotation is NaN. + + #[lua()] + fn is_nan(_self: Val) -> bool; + +"#, + r#" +/// Returns whether `self` has a length of `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if the rotation is near [`Rot2::IDENTITY`]. + + #[lua()] + fn is_near_identity(_self: Val) -> bool; + +"#, + r#" +/// Returns the angle in radians needed to make `self` and `other` coincide. + + #[lua()] + fn angle_between(_self: Val, other: Val) -> f32; + +"#, + r#" +/// Returns the angle in radians needed to make `self` and `other` coincide. + + #[lua()] + fn angle_to(_self: Val, other: Val) -> f32; + +"#, + r#" +/// Returns the inverse of the rotation. This is also the conjugate +/// of the unit complex number representing the rotation. + + #[lua()] + fn inverse(_self: Val) -> Val; + +"#, + 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()] + fn nlerp( + _self: Val, + end: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + end: Val, + s: f32, + ) -> Val; + +"#, + r#" +/// Rotates the [`Dir2`] using a [`Rot2`]. + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + direction: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rot2 { + cos: f32, + sin: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::Dir2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Create a direction from its `x` and `y` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x` and `y` must be normalized, i.e its length must be `1.0`. + + #[lua()] + fn from_xy_unchecked(x: f32, y: f32) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + r#" +/// Get the rotation that rotates this direction to `other`. + + #[lua()] + fn rotation_to( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +/// Get the rotation that rotates `other` to this direction. + + #[lua()] + fn rotation_from( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +/// Get the rotation that rotates the X-axis to this direction. + + #[lua()] + fn rotation_from_x(_self: Val) -> Val; + +"#, + r#" +/// Get the rotation that rotates this direction to the X-axis. + + #[lua()] + fn rotation_to_x(_self: Val) -> Val; + +"#, + r#" +/// Get the rotation that rotates the Y-axis to this direction. + + #[lua()] + fn rotation_from_y(_self: Val) -> Val; + +"#, + r#" +/// Get the rotation that rotates this direction to the Y-axis. + + #[lua()] + fn rotation_to_y(_self: Val) -> Val; + +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. + + #[lua()] + fn fast_renormalize( + _self: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Dir2(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::Dir3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. + + #[lua()] + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// # Example +/// The following seemingly benign code would start accumulating errors over time, +/// leading to `dir` eventually not being normalized anymore. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// } +/// ``` +/// Instead, do the following. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// dir = dir.fast_renormalize(); +/// } +/// ``` + + #[lua()] + fn fast_renormalize( + _self: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Dir3(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::Dir3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. + + #[lua()] + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. + + #[lua()] + fn fast_renormalize( + _self: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Dir3A(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::IRect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + 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()] + fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> Val; + +"#, + 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()] + fn is_empty(_self: Ref) -> 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()] + fn width(_self: Ref) -> 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()] + fn height(_self: Ref) -> i32; + +"#, + 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()] + fn union( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn intersect( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn inflate( + _self: Ref, + expansion: i32, + ) -> Val; + +"#, + r#" +/// Returns self as [`Rect`] (f32) + + #[lua()] + fn as_rect(_self: Ref) -> Val; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[lua()] + fn as_urect( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct IRect { + min: ReflectReference, + max: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::Rect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new rectangle from two corner points. +/// The two points do not need to be the minimum and/or maximum corners. +/// They only need to be two opposite corners. +/// # 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()] + fn new(x0: f32, y0: f32, x1: f32, y1: f32) -> Val; + +"#, + 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()] + fn is_empty(_self: Ref) -> 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()] + fn width(_self: Ref) -> 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()] + fn height(_self: Ref) -> f32; + +"#, + 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()] + fn union( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn intersect( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn inflate( + _self: Ref, + expansion: f32, + ) -> Val; + +"#, + 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()] + fn normalize( + _self: Ref, + other: Val, + ) -> Val; + +"#, + r#" +/// Returns self as [`IRect`] (i32) + + #[lua()] + fn as_irect( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Returns self as [`URect`] (u32) + + #[lua()] + fn as_urect( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rect { + min: ReflectReference, + max: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::prelude::URect", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new rectangle from two corner points. +/// The two points do not need to be the minimum and/or maximum corners. +/// They only need to be two opposite corners. +/// # 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()] + fn new(x0: u32, y0: u32, x1: u32, y1: u32) -> Val; + +"#, + 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()] + fn is_empty(_self: Ref) -> 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()] + fn width(_self: Ref) -> 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()] + fn height(_self: Ref) -> u32; + +"#, + 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()] + fn union( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn intersect( + _self: Ref, + other: Val, + ) -> Val; + +"#, + 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()] + fn inflate( + _self: Ref, + expansion: i32, + ) -> Val; + +"#, + r#" +/// Returns self as [`Rect`] (f32) + + #[lua()] + fn as_rect(_self: Ref) -> Val; + +"#, + r#" +/// Returns self as [`IRect`] (i32) + + #[lua()] + fn as_irect( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct URect { + min: ReflectReference, + max: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Affine3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[] +)] +pub struct Affine3 { + matrix3: ReflectReference, + translation: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::Aabb2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Computes the smallest [`BoundingCircle`] containing this [`Aabb2d`]. + + #[lua()] + fn bounding_circle( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Aabb2d { + min: ReflectReference, + max: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::BoundingCircle", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Get the radius of the bounding circle + + #[lua()] + fn radius(_self: Ref) -> f32; + +"#, + r#" +/// Computes the smallest [`Aabb2d`] containing this [`BoundingCircle`]. + + #[lua()] + fn aabb_2d( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BoundingCircle { + center: ReflectReference, + circle: bevy::math::primitives::Circle, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Circle", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new [`Circle`] from a `radius` + + #[lua()] + fn new(radius: f32) -> Val; + +"#, + r#" +/// Get the diameter of the circle + + #[lua()] + fn diameter(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Circle { + radius: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Annulus", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new [`Annulus`] from the radii of the inner and outer circle + + #[lua()] + fn new(inner_radius: f32, outer_radius: f32) -> Val; + +"#, + r#" +/// Get the diameter of the annulus + + #[lua()] + fn diameter(_self: Ref) -> f32; + +"#, + r#" +/// Get the thickness of the annulus + + #[lua()] + fn thickness(_self: Ref) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Annulus { + inner_circle: bevy::math::primitives::Circle, + outer_circle: bevy::math::primitives::Circle, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Arc2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new [`Arc2d`] from a `radius` and a `half_angle` + + #[lua()] + fn new(radius: f32, half_angle: f32) -> Val; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and an `angle` in radians + + #[lua()] + fn from_radians(radius: f32, angle: f32) -> Val; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and an `angle` in degrees. + + #[lua()] + fn from_degrees(radius: f32, angle: f32) -> Val; + +"#, + r#" +/// Create a new [`Arc2d`] from a `radius` and a `fraction` of a single turn. +/// For instance, `0.5` turns is a semicircle. + + #[lua()] + fn from_turns(radius: f32, fraction: f32) -> Val; + +"#, + r#" +/// Get the angle of the arc + + #[lua()] + fn angle(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the arc + + #[lua()] + fn length(_self: Ref) -> f32; + +"#, + r#" +/// Get half the distance between the endpoints (half the length of the chord) + + #[lua()] + fn half_chord_length(_self: Ref) -> f32; + +"#, + r#" +/// Get the distance between the endpoints (the length of the chord) + + #[lua()] + fn chord_length(_self: Ref) -> f32; + +"#, + 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()] + fn apothem(_self: Ref) -> 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()] + fn sagitta(_self: Ref) -> 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()] + fn is_minor(_self: Ref) -> 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()] + fn is_major(_self: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Arc2d { + radius: f32, + half_angle: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Capsule2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new `Capsule2d` from a radius and length + + #[lua()] + fn new(radius: f32, length: f32) -> Val; + +"#, + r#" +/// Get the part connecting the semicircular ends of the capsule as a [`Rectangle`] + + #[lua()] + fn to_inner_rectangle( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Capsule2d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::CircularSector", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and an `angle` + + #[lua()] + fn new(radius: f32, angle: f32) -> Val; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and an `angle` in radians. + + #[lua()] + fn from_radians( + radius: f32, + angle: f32, + ) -> Val; + +"#, + r#" +/// Create a new [`CircularSector`] from a `radius` and an `angle` in degrees. + + #[lua()] + fn from_degrees( + radius: f32, + angle: f32, + ) -> Val; + +"#, + 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()] + fn from_turns( + radius: f32, + fraction: f32, + ) -> Val; + +"#, + r#" +/// Get half the angle of the sector + + #[lua()] + fn half_angle(_self: Ref) -> f32; + +"#, + r#" +/// Get the angle of the sector + + #[lua()] + fn angle(_self: Ref) -> f32; + +"#, + r#" +/// Get the radius of the sector + + #[lua()] + fn radius(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the arc defining the sector + + #[lua()] + fn arc_length(_self: Ref) -> f32; + +"#, + r#" +/// Get half the length of the chord defined by the sector +/// See [`Arc2d::half_chord_length`] + + #[lua()] + fn half_chord_length(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the chord defined by the sector +/// See [`Arc2d::chord_length`] + + #[lua()] + fn chord_length(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the apothem of this sector +/// See [`Arc2d::apothem`] + + #[lua()] + fn apothem(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the sagitta of this sector +/// See [`Arc2d::sagitta`] + + #[lua()] + fn sagitta(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CircularSector { + arc: bevy::math::primitives::Arc2d, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::CircularSegment", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new [`CircularSegment`] from a `radius`, and an `angle` + + #[lua()] + fn new(radius: f32, angle: f32) -> Val; + +"#, + r#" +/// Create a new [`CircularSegment`] from a `radius` and an `angle` in radians. + + #[lua()] + fn from_radians( + radius: f32, + angle: f32, + ) -> Val; + +"#, + r#" +/// Create a new [`CircularSegment`] from a `radius` and an `angle` in degrees. + + #[lua()] + fn from_degrees( + radius: f32, + angle: f32, + ) -> Val; + +"#, + 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()] + fn from_turns( + radius: f32, + fraction: f32, + ) -> Val; + +"#, + r#" +/// Get the half-angle of the segment + + #[lua()] + fn half_angle(_self: Ref) -> f32; + +"#, + r#" +/// Get the angle of the segment + + #[lua()] + fn angle(_self: Ref) -> f32; + +"#, + r#" +/// Get the radius of the segment + + #[lua()] + fn radius(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the arc defining the segment + + #[lua()] + fn arc_length(_self: Ref) -> f32; + +"#, + r#" +/// Get half the length of the segment's base, also known as its chord + + #[lua()] + fn half_chord_length(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the segment's base, also known as its chord + + #[lua()] + fn chord_length(_self: Ref) -> f32; + +"#, + 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()] + fn apothem(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of the sagitta of this segment, also known as its height +/// See [`Arc2d::sagitta`] + + #[lua()] + fn sagitta(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct CircularSegment { + arc: bevy::math::primitives::Arc2d, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Ellipse", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Ellipse` from half of its width and height. +/// This corresponds to the two perpendicular radii defining the ellipse. + + #[lua()] + fn new(half_width: f32, half_height: f32) -> Val; + +"#, + 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()] + fn eccentricity(_self: Ref) -> 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()] + fn focal_length(_self: Ref) -> f32; + +"#, + r#" +/// Returns the length of the semi-major axis. This corresponds to the longest radius of the ellipse. + + #[lua()] + fn semi_major(_self: Ref) -> f32; + +"#, + r#" +/// Returns the length of the semi-minor axis. This corresponds to the shortest radius of the ellipse. + + #[lua()] + fn semi_minor(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Ellipse { + half_size: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Line2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Line2d { + direction: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Plane2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Plane2d { + normal: bevy::math::prelude::Dir2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Rectangle", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Rectangle` from a full width and height + + #[lua()] + fn new(width: f32, height: f32) -> Val; + +"#, + r#" +/// Create a `Rectangle` from a single length. +/// The resulting `Rectangle` will be the same size in every direction. + + #[lua()] + fn from_length(length: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rectangle { + half_size: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::RegularPolygon", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Create a new `RegularPolygon` +/// from the radius of the circumcircle and a number of sides +/// # Panics +/// Panics if `circumradius` is negative + + #[lua()] + fn new(circumradius: f32, sides: u32) -> Val; + +"#, + r#" +/// Get the radius of the circumcircle on which all vertices +/// of the regular polygon lie + + #[lua()] + fn circumradius(_self: Ref) -> 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()] + fn inradius(_self: Ref) -> f32; + +"#, + r#" +/// Get the length of one side of the regular polygon + + #[lua()] + fn side_length(_self: Ref) -> 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()] + fn internal_angle_degrees(_self: Ref) -> 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()] + fn internal_angle_radians(_self: Ref) -> 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()] + fn external_angle_degrees(_self: Ref) -> 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()] + fn external_angle_radians(_self: Ref) -> f32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RegularPolygon { + circumcircle: bevy::math::primitives::Circle, + sides: u32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Rhombus", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Rhombus` from a vertical and horizontal diagonal sizes. + + #[lua()] + fn new( + horizontal_diagonal: f32, + vertical_diagonal: f32, + ) -> Val; + +"#, + r#" +/// Create a new `Rhombus` from a side length with all inner angles equal. + + #[lua()] + fn from_side(side: f32) -> Val; + +"#, + r#" +/// Create a new `Rhombus` from a given inradius with all inner angles equal. + + #[lua()] + fn from_inradius(inradius: f32) -> Val; + +"#, + r#" +/// Get the length of each side of the rhombus + + #[lua()] + fn side(_self: Ref) -> f32; + +"#, + r#" +/// Get the radius of the circumcircle on which all vertices +/// of the rhombus lie + + #[lua()] + fn circumradius(_self: Ref) -> f32; + +"#, + r#" +/// Get the radius of the largest circle that can +/// be drawn within the rhombus + + #[lua()] + fn inradius(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Rhombus { + half_diagonals: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Segment2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Segment2d` from a direction and full length of the segment + + #[lua()] + fn new( + direction: Val, + length: f32, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Segment2d { + direction: bevy::math::prelude::Dir2, + half_length: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Triangle2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[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()] + fn is_degenerate(_self: Ref) -> bool; + +"#, + r#" +/// Checks if the triangle is acute, meaning all angles are less than 90 degrees + + #[lua()] + fn is_acute(_self: Ref) -> bool; + +"#, + r#" +/// Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees + + #[lua()] + fn is_obtuse(_self: Ref) -> bool; + +"#, + r#" +/// Reverse the [`WindingOrder`] of the triangle +/// by swapping the first and last vertices. + + #[lua()] + fn reverse(_self: Mut) -> (); + +"#, + r#" +/// This triangle but reversed. + + #[lua()] + fn reversed( + _self: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Triangle2d { + vertices: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::Aabb3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Computes the smallest [`BoundingSphere`] containing this [`Aabb3d`]. + + #[lua()] + fn bounding_sphere( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Aabb3d { + min: ReflectReference, + max: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::BoundingSphere", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Get the radius of the bounding sphere + + #[lua()] + fn radius(_self: Ref) -> f32; + +"#, + r#" +/// Computes the smallest [`Aabb3d`] containing this [`BoundingSphere`]. + + #[lua()] + fn aabb_3d( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BoundingSphere { + center: ReflectReference, + sphere: bevy::math::primitives::Sphere, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Sphere", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Create a new [`Sphere`] from a `radius` + + #[lua()] + fn new(radius: f32) -> Val; + +"#, + r#" +/// Get the diameter of the sphere + + #[lua()] + fn diameter(_self: Ref) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Sphere { + radius: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cuboid", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Cuboid` from a full x, y, and z length + + #[lua()] + fn new( + x_length: f32, + y_length: f32, + z_length: f32, + ) -> Val; + +"#, + r#" +/// Create a `Cuboid` from a single length. +/// The resulting `Cuboid` will be the same size in every direction. + + #[lua()] + fn from_length(length: f32) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cuboid { + half_size: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cylinder", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Cylinder` from a radius and full height + + #[lua()] + fn new(radius: f32, height: f32) -> Val; + +"#, + r#" +/// Get the base of the cylinder as a [`Circle`] + + #[lua()] + fn base( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Get the surface area of the side of the cylinder, +/// also known as the lateral area + + #[lua()] + fn lateral_area(_self: Ref) -> f32; + +"#, + r#" +/// Get the surface area of one base of the cylinder + + #[lua()] + fn base_area(_self: Ref) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cylinder { + radius: f32, + half_height: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Capsule3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Create a new `Capsule3d` from a radius and length + + #[lua()] + fn new(radius: f32, length: f32) -> Val; + +"#, + r#" +/// Get the part connecting the hemispherical ends +/// of the capsule as a [`Cylinder`] + + #[lua()] + fn to_cylinder( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Capsule3d { + radius: f32, + half_length: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Cone", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new [`Cone`] from a radius and height. + + #[lua()] + fn new(radius: f32, height: f32) -> Val; + +"#, + r#" +/// Get the base of the cone as a [`Circle`] + + #[lua()] + fn base( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Get the slant height of the cone, the length of the line segment +/// connecting a point on the base to the apex + + #[lua()] + fn slant_height(_self: Ref) -> f32; + +"#, + r#" +/// Get the surface area of the side of the cone, +/// also known as the lateral area + + #[lua()] + fn lateral_area(_self: Ref) -> f32; + +"#, + r#" +/// Get the surface area of the base of the cone + + #[lua()] + fn base_area(_self: Ref) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Cone { + radius: f32, + height: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::ConicalFrustum", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct ConicalFrustum { + radius_top: f32, + radius_bottom: f32, + height: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::InfinitePlane3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct InfinitePlane3d { + normal: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Line3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Line3d { + direction: bevy::math::prelude::Dir3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Segment3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new `Segment3d` from a direction and full length of the segment + + #[lua()] + fn new( + direction: Val, + length: f32, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Segment3d { + direction: bevy::math::prelude::Dir3, + half_length: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Torus", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + 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()] + fn new(inner_radius: f32, outer_radius: f32) -> Val; + +"#, + 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()] + fn inner_radius(_self: Ref) -> 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()] + fn outer_radius(_self: Ref) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Torus { + minor_radius: f32, + major_radius: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Triangle3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + 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()] + fn is_degenerate(_self: Ref) -> bool; + +"#, + r#" +/// Checks if the triangle is acute, meaning all angles are less than 90 degrees + + #[lua()] + fn is_acute(_self: Ref) -> bool; + +"#, + r#" +/// Checks if the triangle is obtuse, meaning one angle is greater than 90 degrees + + #[lua()] + fn is_obtuse(_self: Ref) -> bool; + +"#, + r#" +/// Reverse the triangle by swapping the first and last vertices. + + #[lua()] + fn reverse(_self: Mut) -> (); + +"#, + r#" +/// This triangle but reversed. + + #[lua()] + fn reversed( + _self: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Triangle3d { + vertices: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::RayCast2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Construct a [`RayCast2d`] from a [`Ray2d`] and max distance. + + #[lua()] + fn from_ray( + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance of an intersection with an [`Aabb2d`], if any. + + #[lua()] + fn aabb_intersection_at( + _self: Ref, + aabb: Ref, + ) -> std::option::Option; + +"#, + r#" +/// Get the distance of an intersection with a [`BoundingCircle`], if any. + + #[lua()] + fn circle_intersection_at( + _self: Ref, + circle: Ref, + ) -> std::option::Option; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RayCast2d { + ray: bevy::math::Ray2d, + max: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::AabbCast2d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Construct an [`AabbCast2d`] from an [`Aabb2d`], [`Ray2d`], and max distance. + + #[lua()] + fn from_ray( + aabb: Val, + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance at which the [`Aabb2d`]s collide, if at all. + + #[lua()] + fn aabb_collision_at( + _self: Ref, + aabb: Val, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AabbCast2d { + ray: bevy::math::bounding::RayCast2d, + aabb: bevy::math::bounding::Aabb2d, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::BoundingCircleCast", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Construct a [`BoundingCircleCast`] from a [`BoundingCircle`], [`Ray2d`], and max distance. + + #[lua()] + fn from_ray( + circle: Val, + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance at which the [`BoundingCircle`]s collide, if at all. + + #[lua()] + fn circle_collision_at( + _self: Ref, + circle: Val, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BoundingCircleCast { + ray: bevy::math::bounding::RayCast2d, + circle: bevy::math::bounding::BoundingCircle, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::RayCast3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Construct a [`RayCast3d`] from a [`Ray3d`] and max distance. + + #[lua()] + fn from_ray( + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance of an intersection with an [`Aabb3d`], if any. + + #[lua()] + fn aabb_intersection_at( + _self: Ref, + aabb: Ref, + ) -> std::option::Option; + +"#, + r#" +/// Get the distance of an intersection with a [`BoundingSphere`], if any. + + #[lua()] + fn sphere_intersection_at( + _self: Ref, + sphere: Ref, + ) -> std::option::Option; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RayCast3d { + origin: ReflectReference, + direction: bevy::math::prelude::Dir3A, + max: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::AabbCast3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Construct an [`AabbCast3d`] from an [`Aabb3d`], [`Ray3d`], and max distance. + + #[lua()] + fn from_ray( + aabb: Val, + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance at which the [`Aabb3d`]s collide, if at all. + + #[lua()] + fn aabb_collision_at( + _self: Ref, + aabb: Val, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AabbCast3d { + ray: bevy::math::bounding::RayCast3d, + aabb: bevy::math::bounding::Aabb3d, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::bounding::BoundingSphereCast", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Construct a [`BoundingSphereCast`] from a [`BoundingSphere`], [`Ray3d`], and max distance. + + #[lua()] + fn from_ray( + sphere: Val, + ray: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Get the distance at which the [`BoundingSphere`]s collide, if at all. + + #[lua()] + fn sphere_collision_at( + _self: Ref, + sphere: Val, + ) -> std::option::Option; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BoundingSphereCast { + ray: bevy::math::bounding::RayCast3d, + sphere: bevy::math::bounding::BoundingSphere, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::curve::interval::Interval", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +/// Get the start of this interval. + + #[lua()] + fn start(_self: Val) -> f32; + +"#, + r#" +/// Get the end of this interval. + + #[lua()] + fn end(_self: Val) -> f32; + +"#, + r#" +/// Get the length of this interval. Note that the result may be infinite (`f32::INFINITY`). + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Returns `true` if this interval is bounded — that is, if both its start and end are finite. +/// Equivalently, an interval is bounded if its length is finite. + + #[lua()] + fn is_bounded(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if this interval has a finite start. + + #[lua()] + fn has_finite_start(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if this interval has a finite end. + + #[lua()] + fn has_finite_end(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if `item` is contained in this interval. + + #[lua()] + fn contains(_self: Val, item: f32) -> bool; + +"#, + r#" +/// Returns `true` if the other interval is contained in this interval. +/// This is non-strict: each interval will contain itself. + + #[lua()] + fn contains_interval( + _self: Val, + other: Val, + ) -> bool; + +"#, + r#" +/// Clamp the given `value` to lie within this interval. + + #[lua()] + fn clamp(_self: Val, value: f32) -> f32; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Interval {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::FloatOrd", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd::")] + fn lt(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd::")] + fn le(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd::")] + fn gt(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::PartialOrd::")] + fn ge(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct FloatOrd(f32); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Plane3d", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Plane3d { + normal: bevy::math::prelude::Dir3, + half_size: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::primitives::Tetrahedron", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[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()] + fn signed_volume(_self: Ref) -> f32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Tetrahedron { + vertices: ReflectReference, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::curve::easing::EaseFunction", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct EaseFunction {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "Isometry2d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Isometry3d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Rot2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Dir2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Dir3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Dir3A", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("IRect", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Rect", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("URect", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Circle", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Annulus", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Arc2d", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Capsule2d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "CircularSector", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "CircularSegment", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Ellipse", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rectangle", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "RegularPolygon", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Rhombus", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Segment2d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Sphere", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Cuboid", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Cylinder", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Capsule3d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Cone", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Segment3d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Torus", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "RayCast2d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AabbCast2d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "BoundingCircleCast", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "RayCast3d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AabbCast3d", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "BoundingSphereCast", + crate::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_math_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyMathScriptingPlugin; +impl bevy::app::Plugin for BevyMathScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_math_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyMathAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_reflect.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_reflect.rs new file mode 100644 index 0000000000..a67a254792 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_reflect.rs @@ -0,0 +1,22843 @@ +// @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 bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicBool", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new `AtomicBool`. +/// # Examples +/// ``` +/// use std::sync::atomic::AtomicBool; +/// let atomic_true = AtomicBool::new(true); +/// let atomic_false = AtomicBool::new(false); +/// ``` + + #[lua()] + fn new(v: bool) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +/// use std::sync::atomic::AtomicBool; +/// let some_bool = AtomicBool::new(true); +/// assert_eq!(some_bool.into_inner(), true); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicBool {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicI16", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI16; +///let atomic_forty_two = AtomicI16::new(42); +/// ``` + + #[lua()] + fn new(v: i16) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI16; +///let some_var = AtomicI16::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> i16; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicI16 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicI32", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI32; +///let atomic_forty_two = AtomicI32::new(42); +/// ``` + + #[lua()] + fn new(v: i32) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI32; +///let some_var = AtomicI32::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> i32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicI32 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicI64", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI64; +///let atomic_forty_two = AtomicI64::new(42); +/// ``` + + #[lua()] + fn new(v: i64) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI64; +///let some_var = AtomicI64::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> i64; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicI64 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicI8", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI8; +///let atomic_forty_two = AtomicI8::new(42); +/// ``` + + #[lua()] + fn new(v: i8) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicI8; +///let some_var = AtomicI8::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> i8; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicI8 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicIsize", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicIsize; +///let atomic_forty_two = AtomicIsize::new(42); +/// ``` + + #[lua()] + fn new(v: isize) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicIsize; +///let some_var = AtomicIsize::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> isize; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicIsize {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicU16", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU16; +///let atomic_forty_two = AtomicU16::new(42); +/// ``` + + #[lua()] + fn new(v: u16) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU16; +///let some_var = AtomicU16::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> u16; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicU16 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicU32", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU32; +///let atomic_forty_two = AtomicU32::new(42); +/// ``` + + #[lua()] + fn new(v: u32) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU32; +///let some_var = AtomicU32::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> u32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicU32 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicU64", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU64; +///let atomic_forty_two = AtomicU64::new(42); +/// ``` + + #[lua()] + fn new(v: u64) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU64; +///let some_var = AtomicU64::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> u64; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicU64 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicU8", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU8; +///let atomic_forty_two = AtomicU8::new(42); +/// ``` + + #[lua()] + fn new(v: u8) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicU8; +///let some_var = AtomicU8::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> u8; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicU8 {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::sync::atomic::AtomicUsize", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new atomic integer. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicUsize; +///let atomic_forty_two = AtomicUsize::new(42); +/// ``` + + #[lua()] + fn new(v: usize) -> Val; + +"#, + r#" +/// Consumes the atomic and returns the contained value. +/// This is safe because passing `self` by value guarantees that no other threads are +/// concurrently accessing the atomic data. +/// # Examples +/// ``` +///use std::sync::atomic::AtomicUsize; +///let some_var = AtomicUsize::new(5); +/// assert_eq!(some_var.into_inner(), 5); +/// ``` + + #[lua()] + fn into_inner(_self: Val) -> usize; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct AtomicUsize {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::utils::Duration", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u32) -> Val; + +"#, + 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 +/// nanoseconds in a second), then it will carry over into the seconds provided. +/// # Panics +/// This constructor will panic if the carry from the nanoseconds overflows +/// the seconds counter. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let five_seconds = Duration::new(5, 0); +/// ``` + + #[lua()] + fn new(secs: u64, nanos: u32) -> Val; + +"#, + r#" +/// Creates a new `Duration` from the specified number of whole seconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_secs(5); +/// assert_eq!(5, duration.as_secs()); +/// assert_eq!(0, duration.subsec_nanos()); +/// ``` + + #[lua()] + fn from_secs(secs: u64) -> Val; + +"#, + r#" +/// Creates a new `Duration` from the specified number of milliseconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(2_569); +/// assert_eq!(2, duration.as_secs()); +/// assert_eq!(569_000_000, duration.subsec_nanos()); +/// ``` + + #[lua()] + fn from_millis(millis: u64) -> Val; + +"#, + r#" +/// Creates a new `Duration` from the specified number of microseconds. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_micros(1_000_002); +/// assert_eq!(1, duration.as_secs()); +/// assert_eq!(2_000, duration.subsec_nanos()); +/// ``` + + #[lua()] + fn from_micros(micros: u64) -> Val; + +"#, + 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; +/// let duration = Duration::from_nanos(1_000_000_123); +/// assert_eq!(1, duration.as_secs()); +/// assert_eq!(123, duration.subsec_nanos()); +/// ``` + + #[lua()] + fn from_nanos(nanos: u64) -> Val; + +"#, + r#" +/// Returns true if this `Duration` spans no time. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert!(Duration::ZERO.is_zero()); +/// assert!(Duration::new(0, 0).is_zero()); +/// assert!(Duration::from_nanos(0).is_zero()); +/// assert!(Duration::from_secs(0).is_zero()); +/// assert!(!Duration::new(1, 1).is_zero()); +/// assert!(!Duration::from_nanos(1).is_zero()); +/// assert!(!Duration::from_secs(1).is_zero()); +/// ``` + + #[lua()] + fn is_zero(_self: Ref) -> bool; + +"#, + r#" +/// Returns the number of _whole_ seconds contained by this `Duration`. +/// The returned value does not include the fractional (nanosecond) part of the +/// duration, which can be obtained using [`subsec_nanos`]. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_secs(), 5); +/// ``` +/// To determine the total number of seconds represented by the `Duration` +/// including the fractional part, use [`as_secs_f64`] or [`as_secs_f32`] +/// [`as_secs_f64`]: Duration::as_secs_f64 +/// [`as_secs_f32`]: Duration::as_secs_f32 +/// [`subsec_nanos`]: Duration::subsec_nanos + + #[lua()] + fn as_secs(_self: Ref) -> u64; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in whole milliseconds. +/// This method does **not** return the length of the duration when +/// represented by milliseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one thousand). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(5_432); +/// assert_eq!(duration.as_secs(), 5); +/// assert_eq!(duration.subsec_millis(), 432); +/// ``` + + #[lua()] + fn subsec_millis(_self: Ref) -> u32; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in whole microseconds. +/// This method does **not** return the length of the duration when +/// represented by microseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one million). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_micros(1_234_567); +/// assert_eq!(duration.as_secs(), 1); +/// assert_eq!(duration.subsec_micros(), 234_567); +/// ``` + + #[lua()] + fn subsec_micros(_self: Ref) -> u32; + +"#, + r#" +/// Returns the fractional part of this `Duration`, in nanoseconds. +/// This method does **not** return the length of the duration when +/// represented by nanoseconds. The returned number always represents a +/// fractional portion of a second (i.e., it is less than one billion). +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::from_millis(5_010); +/// assert_eq!(duration.as_secs(), 5); +/// assert_eq!(duration.subsec_nanos(), 10_000_000); +/// ``` + + #[lua()] + fn subsec_nanos(_self: Ref) -> u32; + +"#, + r#" +/// Returns the total number of whole milliseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_millis(), 5_730); +/// ``` + + #[lua()] + fn as_millis(_self: Ref) -> u128; + +"#, + r#" +/// Returns the total number of whole microseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_micros(), 5_730_023); +/// ``` + + #[lua()] + fn as_micros(_self: Ref) -> u128; + +"#, + r#" +/// Returns the total number of nanoseconds contained by this `Duration`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let duration = Duration::new(5, 730_023_852); +/// assert_eq!(duration.as_nanos(), 5_730_023_852); +/// ``` + + #[lua()] + fn as_nanos(_self: Ref) -> u128; + +"#, + r#" +/// Computes the absolute difference between `self` and `other`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0)); +/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000)); +/// ``` + + #[lua()] + fn abs_diff( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +/// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] +/// if overflow occurred. +/// # Examples +/// ``` +/// #![feature(duration_constants)] +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1)); +/// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX); +/// ``` + + #[lua()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`] +/// if the result would be negative or if overflow occurred. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); +/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO); +/// ``` + + #[lua()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Saturating `Duration` multiplication. Computes `self * other`, returning +/// [`Duration::MAX`] if overflow occurred. +/// # Examples +/// ``` +/// #![feature(duration_constants)] +/// use std::time::Duration; +/// assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2)); +/// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX); +/// ``` + + #[lua()] + fn saturating_mul( + _self: Val, + rhs: u32, + ) -> Val; + +"#, + r#" +/// Returns the number of seconds contained by this `Duration` as `f64`. +/// The returned value includes the fractional (nanosecond) part of the duration. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.as_secs_f64(), 2.7); +/// ``` + + #[lua()] + fn as_secs_f64(_self: Ref) -> f64; + +"#, + r#" +/// Returns the number of seconds contained by this `Duration` as `f32`. +/// The returned value includes the fractional (nanosecond) part of the duration. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.as_secs_f32(), 2.7); +/// ``` + + #[lua()] + fn as_secs_f32(_self: Ref) -> f32; + +"#, + r#" +/// Creates a new `Duration` from the specified number of seconds represented +/// as `f64`. +/// # Panics +/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let res = Duration::from_secs_f64(0.0); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f64(1e-20); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f64(4.2e-7); +/// assert_eq!(res, Duration::new(0, 420)); +/// let res = Duration::from_secs_f64(2.7); +/// assert_eq!(res, Duration::new(2, 700_000_000)); +/// let res = Duration::from_secs_f64(3e10); +/// assert_eq!(res, Duration::new(30_000_000_000, 0)); +/// // subnormal float +/// let res = Duration::from_secs_f64(f64::from_bits(1)); +/// assert_eq!(res, Duration::new(0, 0)); +/// // conversion uses rounding +/// let res = Duration::from_secs_f64(0.999e-9); +/// assert_eq!(res, Duration::new(0, 1)); +/// ``` + + #[lua()] + fn from_secs_f64(secs: f64) -> Val; + +"#, + r#" +/// Creates a new `Duration` from the specified number of seconds represented +/// as `f32`. +/// # Panics +/// This constructor will panic if `secs` is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let res = Duration::from_secs_f32(0.0); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f32(1e-20); +/// assert_eq!(res, Duration::new(0, 0)); +/// let res = Duration::from_secs_f32(4.2e-7); +/// assert_eq!(res, Duration::new(0, 420)); +/// let res = Duration::from_secs_f32(2.7); +/// assert_eq!(res, Duration::new(2, 700_000_048)); +/// let res = Duration::from_secs_f32(3e10); +/// assert_eq!(res, Duration::new(30_000_001_024, 0)); +/// // subnormal float +/// let res = Duration::from_secs_f32(f32::from_bits(1)); +/// assert_eq!(res, Duration::new(0, 0)); +/// // conversion uses rounding +/// let res = Duration::from_secs_f32(0.999e-9); +/// assert_eq!(res, Duration::new(0, 1)); +/// ``` + + #[lua()] + fn from_secs_f32(secs: f32) -> Val; + +"#, + r#" +/// Multiplies `Duration` by `f64`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); +/// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); +/// ``` + + #[lua()] + fn mul_f64( + _self: Val, + rhs: f64, + ) -> Val; + +"#, + r#" +/// Multiplies `Duration` by `f32`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); +/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0)); +/// ``` + + #[lua()] + fn mul_f32( + _self: Val, + rhs: f32, + ) -> Val; + +"#, + r#" +/// Divides `Duration` by `f64`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); +/// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_599)); +/// ``` + + #[lua()] + fn div_f64( + _self: Val, + rhs: f64, + ) -> Val; + +"#, + r#" +/// Divides `Duration` by `f32`. +/// # Panics +/// This method will panic if result is negative, overflows `Duration` or not finite. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur = Duration::new(2, 700_000_000); +/// // note that due to rounding errors result is slightly +/// // different from 0.859_872_611 +/// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_580)); +/// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_599)); +/// ``` + + #[lua()] + fn div_f32( + _self: Val, + rhs: f32, + ) -> Val; + +"#, + r#" +/// Divides `Duration` by `Duration` and returns `f64`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur1 = Duration::new(2, 700_000_000); +/// let dur2 = Duration::new(5, 400_000_000); +/// assert_eq!(dur1.div_duration_f64(dur2), 0.5); +/// ``` + + #[lua()] + fn div_duration_f64( + _self: Val, + rhs: Val, + ) -> f64; + +"#, + r#" +/// Divides `Duration` by `Duration` and returns `f32`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur1 = Duration::new(2, 700_000_000); +/// let dur2 = Duration::new(5, 400_000_000); +/// assert_eq!(dur1.div_duration_f32(dur2), 0.5); +/// ``` + + #[lua()] + fn div_duration_f32( + _self: Val, + rhs: Val, + ) -> f32; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Duration {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::utils::Instant", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Panics +/// Previous Rust versions panicked when `other` was later than `self`. Currently this +/// method saturates. Future versions may reintroduce the panic in some circumstances. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +/// Returns an instant corresponding to "now". +/// # Examples +/// ``` +/// use std::time::Instant; +/// let now = Instant::now(); +/// ``` + + #[lua()] + fn now() -> Val; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Panics +/// Previous Rust versions panicked when `earlier` was later than `self`. Currently this +/// method saturates. Future versions may reintroduce the panic in some circumstances. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity +/// # Examples +/// ```no_run +/// use std::time::{Duration, Instant}; +/// use std::thread::sleep; +/// let now = Instant::now(); +/// sleep(Duration::new(1, 0)); +/// let new_now = Instant::now(); +/// println!("{:?}", new_now.duration_since(now)); +/// println!("{:?}", now.duration_since(new_now)); // 0ns +/// ``` + + #[lua()] + fn duration_since( + _self: Ref, + earlier: Val, + ) -> Val; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, +/// or zero duration if that instant is later than this one. +/// # Examples +/// ```no_run +/// use std::time::{Duration, Instant}; +/// use std::thread::sleep; +/// let now = Instant::now(); +/// sleep(Duration::new(1, 0)); +/// let new_now = Instant::now(); +/// println!("{:?}", new_now.saturating_duration_since(now)); +/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns +/// ``` + + #[lua()] + fn saturating_duration_since( + _self: Ref, + earlier: Val, + ) -> Val; + +"#, + 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 +/// method returns a Duration of zero in that case. Future versions may reintroduce the panic. +/// See [Monotonicity]. +/// [Monotonicity]: Instant#monotonicity +/// # Examples +/// ```no_run +/// use std::thread::sleep; +/// use std::time::{Duration, Instant}; +/// let instant = Instant::now(); +/// let three_secs = Duration::from_secs(3); +/// sleep(three_secs); +/// assert!(instant.elapsed() >= three_secs); +/// ``` + + #[lua()] + fn elapsed(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + 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::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + other: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Instant(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "std::ops::RangeFull", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct RangeFull {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Quat", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + 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()] + fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> Val; + +"#, + 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()] + fn from_array(a: [f32; 4]) -> Val; + +"#, + 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()] + fn from_vec4(v: Val) -> Val; + +"#, + 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()] + fn from_axis_angle(axis: Val, angle: f32) -> Val; + +"#, + r#" +/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. +/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. + + #[lua()] + fn from_scaled_axis(v: Val) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua()] + fn from_rotation_x(angle: f32) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua()] + fn from_rotation_y(angle: f32) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua()] + fn from_rotation_z(angle: f32) -> Val; + +"#, + r#" +/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). + + #[lua()] + fn from_euler( + euler: Val, + a: f32, + b: f32, + c: f32, + ) -> Val; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_mat3(mat: Ref) -> Val; + +"#, + r#" +/// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_mat3a(mat: Ref) -> Val; + +"#, + r#" +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua()] + fn from_mat4(mat: Ref) -> Val; + +"#, + 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()] + fn from_rotation_arc( + from: Val, + to: Val, + ) -> Val; + +"#, + 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()] + fn from_rotation_arc_colinear( + from: Val, + to: Val, + ) -> Val; + +"#, + 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()] + fn from_rotation_arc_2d( + from: Val, + to: Val, + ) -> Val; + +"#, + r#" +/// Returns the rotation axis scaled by the rotation in radians. + + #[lua()] + fn to_scaled_axis(_self: Val) -> Val; + +"#, + r#" +/// Returns the rotation angles for the given euler rotation sequence. + + #[lua()] + fn to_euler( + _self: Val, + order: Val, + ) -> (f32, f32, f32); + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [f32; 4]; + +"#, + r#" +/// Returns the vector part of the quaternion. + + #[lua()] + fn xyz(_self: Val) -> Val; + +"#, + r#" +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. + + #[lua()] + fn conjugate(_self: Val) -> Val; + +"#, + 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()] + fn inverse(_self: Val) -> Val; + +"#, + 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()] + fn dot(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is generally faster than `length()` as it avoids a square +/// root operation. + + #[lua()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f32; + +"#, + 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()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NAN`. + + #[lua()] + fn is_nan(_self: Val) -> bool; + +"#, + r#" +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua()] + fn is_normalized(_self: Val) -> bool; + +"#, + r#" + + #[lua()] + fn is_near_identity(_self: Val) -> 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()] + fn angle_between(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua()] + fn rotate_towards( + _self: Ref, + rhs: Val, + max_angle: f32, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + max_abs_diff: f32, + ) -> 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()] + fn lerp( + _self: Val, + end: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + end: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn mul_vec3( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn mul_quat( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. + + #[lua()] + fn from_affine3(a: Ref) -> Val; + +"#, + r#" +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. + + #[lua()] + fn mul_vec3a( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua()] + fn as_dquat(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + 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::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + 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::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Quat(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::Vec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::Vec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::Vec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::Vec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::Vec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f32, y: f32, z: f32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f32; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [f32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: f32) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: f32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f32) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f32, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f32, + max: f32, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max(_self: Val, max: f32) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min(_self: Val, min: f32) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f32, + ) -> Val; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +π]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua()] + fn angle_between(_self: Val, rhs: Val) -> 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()] + fn any_orthogonal_vector(_self: Ref) -> Val; + +"#, + 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()] + fn any_orthonormal_vector(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct Vec3 { + x: f32, + y: f32, + z: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::IVec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::IVec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::IVec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::IVec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::IVec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i32) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i32, y: i32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i32; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [i32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: i32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> i32; + +"#, + 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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 + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua()] + fn perp(_self: Val) -> Val; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua()] + fn perp_dot(_self: Val, rhs: Val) -> 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()] + fn rotate( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec2(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct IVec2 { + x: i32, + y: i32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i32, y: i32, z: i32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i32; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [i32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: i32) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: i32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> i32; + +"#, + 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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 + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3a(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::IVec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::IVec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::IVec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::IVec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::IVec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct IVec3 { + x: i32, + y: i32, + z: i32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::IVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::IVec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::IVec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i32, y: i32, z: i32, w: i32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i32; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [i32; 4]; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: i32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: i32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> i32; + +"#, + 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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 + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec4(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::IVec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::IVec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::IVec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i32) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: i32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct IVec4 { + x: i32, + y: i32, + z: i32, + w: i32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::I64Vec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::I64Vec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::I64Vec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i64, y: i64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i64; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [i64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: i64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua()] + fn perp(_self: Val) -> Val; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua()] + fn perp_dot(_self: Val, rhs: Val) -> 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()] + fn rotate( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec2(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::I64Vec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::I64Vec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct I64Vec2 { + x: i64, + y: i64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::I64Vec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::I64Vec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::I64Vec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::I64Vec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i64, y: i64, z: i64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i64; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [i64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: i64) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: i64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3a(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::I64Vec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct I64Vec3 { + x: i64, + y: i64, + z: i64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::I64Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::I64Vec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::I64Vec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::I64Vec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::I64Vec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::I64Vec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: i64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: i64, y: i64, z: i64, w: i64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: i64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [i64; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [i64; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`I64Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: i64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: i64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: i64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: i64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> i64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> i64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> i64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> i64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> u32; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> i64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> 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()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec4(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`. + + #[lua()] + fn saturating_add_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub_unsigned( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: i64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct I64Vec4 { + x: i64, + y: i64, + z: i64, + w: i64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::UVec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::UVec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u32, y: u32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u32; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [u32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: u32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec2(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::UVec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::UVec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::UVec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u32) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct UVec2 { + x: u32, + y: u32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::UVec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::UVec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u32, y: u32, z: u32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u32; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [u32; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: u32) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: u32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3a(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::UVec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::UVec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::UVec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct UVec3 { + x: u32, + y: u32, + z: u32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::UVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::UVec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u32, y: u32, z: u32, w: u32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u32; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [u32; 4]; + +"#, + 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()]. + + #[lua()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: u32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: u32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u32; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec4(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::UVec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::UVec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::UVec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::UVec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u32) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: u32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct UVec4 { + x: u32, + y: u32, + z: u32, + w: u32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::U64Vec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::U64Vec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::U64Vec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::U64Vec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u64, y: u64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u64; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [u64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: u64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec2(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::U64Vec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct U64Vec2 { + x: u64, + y: u64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::U64Vec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::U64Vec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::U64Vec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::U64Vec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u64) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u64, y: u64, z: u64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u64; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [u64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: u64) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: u64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3a(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::U64Vec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct U64Vec3 { + x: u64, + y: u64, + z: u64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::U64Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::U64Vec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::U64Vec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::U64Vec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::U64Vec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::U64Vec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: u64, y: u64, z: u64, w: u64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: u64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [u64; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [u64; 4]; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: u64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: u64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: u64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: u64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> u64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> u64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> u64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> u64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the squared length of `self`. + + #[lua()] + fn length_squared(_self: Val) -> u64; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec4(_self: Ref) -> Val; + +"#, + 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()] + fn wrapping_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn wrapping_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn saturating_add_signed( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: u64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: u64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct U64Vec4 { + x: u64, + y: u64, + z: u64, + w: u64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::Vec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f32, y: f32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f32; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [f32; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: f32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f32) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f32) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f32, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f32, + max: f32, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max(_self: Val, max: f32) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min(_self: Val, min: f32) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f32, + ) -> Val; + +"#, + 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()] + fn from_angle(angle: f32) -> Val; + +"#, + 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()] + fn to_angle(_self: Val) -> f32; + +"#, + r#" + + #[lua()] + fn angle_between(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-π, +π]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua()] + fn angle_to(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua()] + fn perp(_self: Val) -> Val; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua()] + fn perp_dot(_self: Val, rhs: Val) -> f32; + +"#, + 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()] + fn rotate( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. + + #[lua()] + fn rotate_towards( + _self: Ref, + rhs: Val, + max_angle: f32, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec2(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::Vec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::Vec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::Vec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::Vec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct Vec2 { + x: f32, + y: f32, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::Vec3A>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::Vec3A>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f32) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f32, y: f32, z: f32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f32; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [f32; 3]; + +"#, + r#" +/// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. +/// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. + + #[lua()] + fn from_vec4(v: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: f32) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f32) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: f32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f32) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f32, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f32, + max: f32, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max( + _self: Val, + max: f32, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min( + _self: Val, + min: f32, + ) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f32, + ) -> Val; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +π]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua()] + fn angle_between(_self: Val, rhs: Val) -> 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()] + fn any_orthogonal_vector(_self: Ref) -> Val; + +"#, + 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()] + fn any_orthonormal_vector(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::Vec3A>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::Vec3A>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::Vec3A>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct Vec3A(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Vec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f32, y: f32, z: f32, w: f32) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f32) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f32; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [f32; 4]; + +"#, + r#" +/// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. +/// Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. +/// To truncate to [`Vec3A`] use [`Vec3A::from()`]. + + #[lua()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: f32) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: f32) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f32; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f32; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f32; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f32; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f32; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f32; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared(_self: Val, rhs: Val) -> f32; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f32::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f32) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f32, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f32, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f32, + max: f32, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max(_self: Val, max: f32) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min(_self: Val, min: f32) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f32, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua()] + fn as_dvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec4(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::Vec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::Vec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::Vec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::Vec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::Vec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f32) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct Vec4(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +/// Creates a new vector mask. + + #[lua()] + fn new(x: bool, y: bool) -> Val; + +"#, + r#" +/// Creates a vector mask with all elements set to `v`. + + #[lua()] + fn splat(v: bool) -> Val; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua()] + fn from_array(a: [bool; 2]) -> Val; + +"#, + 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. + + #[lua()] + fn bitmask(_self: Val) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua()] + fn any(_self: Val) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua()] + fn all(_self: Val) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 1. + + #[lua()] + fn test(_self: Ref, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 1. + + #[lua()] + fn set(_self: Mut, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BVec2 { + x: bool, + y: bool, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +/// Creates a new vector mask. + + #[lua()] + fn new(x: bool, y: bool, z: bool) -> Val; + +"#, + r#" +/// Creates a vector mask with all elements set to `v`. + + #[lua()] + fn splat(v: bool) -> Val; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua()] + fn from_array(a: [bool; 3]) -> Val; + +"#, + 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()] + fn bitmask(_self: Val) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua()] + fn any(_self: Val) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua()] + fn all(_self: Val) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. + + #[lua()] + fn test(_self: Ref, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. + + #[lua()] + fn set(_self: Mut, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BVec3 { + x: bool, + y: bool, + z: bool, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +/// Creates a new vector mask. + + #[lua()] + fn new(x: bool, y: bool, z: bool, w: bool) -> Val; + +"#, + r#" +/// Creates a vector mask with all elements set to `v`. + + #[lua()] + fn splat(v: bool) -> Val; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua()] + fn from_array(a: [bool; 4]) -> Val; + +"#, + 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()] + fn bitmask(_self: Val) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua()] + fn any(_self: Val) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua()] + fn all(_self: Val) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. + + #[lua()] + fn test(_self: Ref, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. + + #[lua()] + fn set(_self: Mut, index: usize, value: bool) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BVec4 { + x: bool, + y: bool, + z: bool, + w: bool, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f64, y: f64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f64; 2]) -> Val; + +"#, + r#" +/// `[x, y]` + + #[lua()] + fn to_array(_self: Ref) -> [f64; 2]; + +"#, + r#" +/// Creates a 3D vector from `self` and the given `z` value. + + #[lua()] + fn extend(_self: Val, z: f64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f64) -> Val; + +"#, + r#" +/// Creates a 2D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f64) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f64, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f64, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f64, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max( + _self: Val, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min( + _self: Val, + min: f64, + ) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f64, + ) -> Val; + +"#, + 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()] + fn from_angle(angle: f64) -> Val; + +"#, + 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()] + fn to_angle(_self: Val) -> f64; + +"#, + r#" + + #[lua()] + fn angle_between(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-π, +π]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua()] + fn angle_to(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua()] + fn perp(_self: Val) -> Val; + +"#, + r#" +/// The perpendicular dot product of `self` and `rhs`. +/// Also known as the wedge product, 2D cross product, and determinant. + + #[lua()] + fn perp_dot(_self: Val, rhs: Val) -> f64; + +"#, + 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()] + fn rotate( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. + + #[lua()] + fn rotate_towards( + _self: Ref, + rhs: Val, + max_angle: f64, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec2(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec2(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::DVec2>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::DVec2>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::DVec2>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::DVec2>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::DVec2>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct DVec2 { + x: f64, + y: f64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::DVec3>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::DVec3>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::DVec3>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::DVec3>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f64, y: f64, z: f64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f64; 3]) -> Val; + +"#, + r#" +/// `[x, y, z]` + + #[lua()] + fn to_array(_self: Ref) -> [f64; 3]; + +"#, + r#" +/// Creates a 4D vector from `self` and the given `w` value. + + #[lua()] + fn extend(_self: Val, w: f64) -> Val; + +"#, + 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()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f64) -> Val; + +"#, + r#" +/// Creates a 3D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: f64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Computes the cross product of `self` and `rhs`. + + #[lua()] + fn cross( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f64) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f64, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f64, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f64, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max( + _self: Val, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min( + _self: Val, + min: f64, + ) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f64, + ) -> Val; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +π]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua()] + fn angle_between(_self: Val, rhs: Val) -> f64; + +"#, + 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()] + fn any_orthogonal_vector(_self: Ref) -> Val; + +"#, + 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()] + fn any_orthonormal_vector(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec3a(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec3(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec3(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::DVec3>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct DVec3 { + x: f64, + y: f64, + z: f64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DVec4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Rem::<&bevy::math::DVec4>", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" +/// Creates a new vector. + + #[lua()] + fn new(x: f64, y: f64, z: f64, w: f64) -> Val; + +"#, + r#" +/// Creates a vector with all elements set to `v`. + + #[lua()] + fn splat(v: f64) -> Val; + +"#, + 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()] + fn select( + mask: Val, + if_true: Val, + if_false: Val, + ) -> Val; + +"#, + r#" +/// Creates a new vector from an array. + + #[lua()] + fn from_array(a: [f64; 4]) -> Val; + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [f64; 4]; + +"#, + 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()]. + + #[lua()] + fn truncate(_self: Val) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `x`. + + #[lua()] + fn with_x(_self: Val, x: f64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `y`. + + #[lua()] + fn with_y(_self: Val, y: f64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `z`. + + #[lua()] + fn with_z(_self: Val, z: f64) -> Val; + +"#, + r#" +/// Creates a 4D vector from `self` with the given value of `w`. + + #[lua()] + fn with_w(_self: Val, w: f64) -> Val; + +"#, + r#" +/// Computes the dot product of `self` and `rhs`. + + #[lua()] + fn dot(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua()] + fn dot_into_vec( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn min( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn max( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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. + + #[lua()] + fn clamp( + _self: Val, + min: Val, + max: Val, + ) -> Val; + +"#, + r#" +/// Returns the horizontal minimum of `self`. +/// In other words this computes `min(x, y, ..)`. + + #[lua()] + fn min_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the horizontal maximum of `self`. +/// In other words this computes `max(x, y, ..)`. + + #[lua()] + fn max_element(_self: Val) -> f64; + +"#, + r#" +/// Returns the sum of all elements of `self`. +/// In other words, this computes `self.x + self.y + ..`. + + #[lua()] + fn element_sum(_self: Val) -> f64; + +"#, + r#" +/// Returns the product of all elements of `self`. +/// In other words, this computes `self.x * self.y * ..`. + + #[lua()] + fn element_product(_self: Val) -> f64; + +"#, + 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()] + fn cmpeq( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpne( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpge( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmpgt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmple( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn cmplt( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns a vector containing the absolute value of each element of `self`. + + #[lua()] + fn abs(_self: Val) -> Val; + +"#, + 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()] + fn signum(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua()] + fn copysign( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_negative_bitmask(_self: Val) -> 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`. + + #[lua()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua()] + fn is_finite_mask(_self: Val) -> Val; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Val) -> 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(), ...]`. + + #[lua()] + fn is_nan_mask(_self: Val) -> Val; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is faster than `length()` as it avoids a square root operation. + + #[lua()] + fn length_squared(_self: Val) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> f64; + +"#, + r#" +/// Computes the Euclidean distance between two points in space. + + #[lua()] + fn distance(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Compute the squared euclidean distance between two points in space. + + #[lua()] + fn distance_squared( + _self: Val, + rhs: Val, + ) -> f64; + +"#, + r#" +/// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`. + + #[lua()] + fn div_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`. +/// [Euclidean division]: f64::rem_euclid + + #[lua()] + fn rem_euclid( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Returns `self` normalized to length 1.0. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. +/// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. +/// Panics +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. + + #[lua()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn normalize_or( + _self: Val, + fallback: Val, + ) -> Val; + +"#, + 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()] + fn normalize_or_zero(_self: Val) -> Val; + +"#, + r#" +/// Returns whether `self` is length `1.0` or not. +/// Uses a precision threshold of approximately `1e-4`. + + #[lua()] + fn is_normalized(_self: Val) -> 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()] + fn project_onto( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn project_onto_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn reject_from_normalized( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn round(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the largest integer less than or equal to a number for each +/// element of `self`. + + #[lua()] + fn floor(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the smallest integer greater than or equal to a number for +/// each element of `self`. + + #[lua()] + fn ceil(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing the integer part each element of `self`. This means numbers are +/// always truncated towards zero. + + #[lua()] + fn trunc(_self: Val) -> Val; + +"#, + 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()] + fn fract(_self: Val) -> Val; + +"#, + 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()] + fn fract_gl(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing `e^self` (the exponential function) for each element of +/// `self`. + + #[lua()] + fn exp(_self: Val) -> Val; + +"#, + r#" +/// Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua()] + fn powf(_self: Val, n: f64) -> Val; + +"#, + r#" +/// Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua()] + fn recip(_self: Val) -> Val; + +"#, + 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()] + fn lerp( + _self: Val, + rhs: Val, + s: f64, + ) -> Val; + +"#, + 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()] + fn move_towards( + _self: Ref, + rhs: Val, + d: f64, + ) -> Val; + +"#, + 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()] + fn midpoint( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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`, or if either `min` or `max` is negative, when `glam_assert` is enabled. + + #[lua()] + fn clamp_length( + _self: Val, + min: f64, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_max( + _self: Val, + max: f64, + ) -> Val; + +"#, + r#" +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. + + #[lua()] + fn clamp_length_min( + _self: Val, + min: f64, + ) -> Val; + +"#, + 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()] + fn mul_add( + _self: Val, + a: Val, + b: Val, + ) -> Val; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn reflect( + _self: Val, + normal: Val, + ) -> Val; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn refract( + _self: Val, + normal: Val, + eta: f64, + ) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua()] + fn as_vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua()] + fn as_ivec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua()] + fn as_uvec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua()] + fn as_i64vec4(_self: Ref) -> Val; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua()] + fn as_u64vec4(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::<&bevy::math::DVec4>", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::<&bevy::math::DVec4>", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::<&bevy::math::DVec4>", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Sub::", composite = "sub", metamethod = "Sub")] + fn sub(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Rem::", composite = "rem", metamethod = "Mod")] + fn rem(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Add::", composite = "add", metamethod = "Add")] + fn add(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem::", + composite = "rem", + metamethod = "Mod", + )] + fn rem( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div::<&bevy::math::DVec4>", + composite = "div", + metamethod = "Div", + )] + fn div( + _self: Val, + rhs: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index")] +fn index(self, idx: usize) -> LuaIdentityProxy { + _self[idx - 1] +} +"#, + r#" +#[lua(metamethod="NewIndex")] +fn index(&mut self, idx: usize, val: f64) -> () { + _self[idx - 1] = val +} +"#] +)] +pub struct DVec4 { + x: f64, + y: f64, + z: f64, + w: f64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from two column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + ) -> Val; + +"#, + 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()] + fn to_cols_array(_self: Ref) -> [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()] + fn to_cols_array_2d(_self: Ref) -> [[f32; 2]; 2]; + +"#, + r#" +/// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of +/// `angle` (in radians). + + #[lua()] + fn from_scale_angle( + scale: Val, + angle: f32, + ) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua()] + fn from_angle(angle: f32) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua()] + fn from_mat3_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua()] + fn from_mat3a(m: Val) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua()] + fn from_mat3a_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f32; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Transforms a 2D vector. + + #[lua()] + fn mul_vec2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 2x2 matrices. + + #[lua()] + fn mul_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 2x2 matrices. + + #[lua()] + fn add_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 2x2 matrices. + + #[lua()] + fn sub_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 2x2 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + r#" +/// Divides a 2x2 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f32, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_dmat2(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct Mat2(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f32; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array(_self: Ref) -> [f32; 9]; + +"#, + r#" +/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f32; 3]; 3]; + +"#, + r#" +/// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua()] + fn from_mat4(m: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua()] + fn from_mat4_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given quaternion. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in +/// radians). +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_axis_angle(axis: Val, angle: f32) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in +/// radians). + + #[lua()] + fn from_euler( + order: Val, + a: f32, + b: f32, + c: f32, + ) -> Val; + +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn to_euler( + _self: Ref, + order: Val, + ) -> (f32, f32, f32); + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua()] + fn from_rotation_x(angle: f32) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua()] + fn from_rotation_y(angle: f32) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua()] + fn from_rotation_z(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D rotation `angle` (in +/// radians). +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_angle(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in +/// radians) and `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_scale_angle_translation( + scale: Val, + angle: f32, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given non-uniform 2D `scale`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. +/// # Panics +/// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2x2 matrix. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_mat2(m: Val) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f32; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Transforms the given 2D vector as a point. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_point2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Rotates the given 2D vector. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_vector2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua()] + fn mul_vec3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a [`Vec3A`]. + + #[lua()] + fn mul_vec3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua()] + fn mul_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua()] + fn add_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua()] + fn sub_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f32, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_dmat3(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct Mat3 { + x_axis: bevy::math::Vec3, + y_axis: bevy::math::Vec3, + z_axis: bevy::math::Vec3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f32; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array(_self: Ref) -> [f32; 9]; + +"#, + r#" +/// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f32; 3]; 3]; + +"#, + r#" +/// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua()] + fn from_mat4(m: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua()] + fn from_mat4_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given quaternion. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in +/// radians). +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_axis_angle( + axis: Val, + angle: f32, + ) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in +/// radians). + + #[lua()] + fn from_euler( + order: Val, + a: f32, + b: f32, + c: f32, + ) -> Val; + +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn to_euler( + _self: Ref, + order: Val, + ) -> (f32, f32, f32); + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua()] + fn from_rotation_x(angle: f32) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua()] + fn from_rotation_y(angle: f32) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua()] + fn from_rotation_z(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D rotation `angle` (in +/// radians). +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_angle(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in +/// radians) and `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_scale_angle_translation( + scale: Val, + angle: f32, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given non-uniform 2D `scale`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. +/// # Panics +/// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2x2 matrix. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_mat2(m: Val) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f32; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Transforms the given 2D vector as a point. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_point2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Rotates the given 2D vector. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_vector2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua()] + fn mul_vec3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a [`Vec3A`]. + + #[lua()] + fn mul_vec3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua()] + fn mul_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua()] + fn add_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua()] + fn sub_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f32, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_dmat3(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct Mat3A { + x_axis: bevy::math::Vec3A, + y_axis: bevy::math::Vec3A, + z_axis: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Mat4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f32) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f32) -> Val; + +"#, + r#" +/// Creates a 4x4 matrix from four column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + w_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f32; 16]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array(_self: Ref) -> [f32; 16]; + +"#, + r#" +/// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f32; 4]; 4]; + +"#, + r#" +/// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `scale`, `rotation` and +/// `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_scale_rotation_translation( + scale: Val, + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_rotation_translation( + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given `rotation` quaternion. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3x3 linear transformation +/// matrix. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3x3 linear transformation +/// matrix. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_mat3a(m: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_axis_angle(axis: Val, angle: f32) -> Val; + +"#, + r#" +/// Creates a affine transformation matrix containing a rotation from the given euler +/// rotation sequence and angles (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_euler( + order: Val, + a: f32, + b: f32, + c: f32, + ) -> Val; + +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua()] + fn to_euler( + _self: Ref, + order: Val, + ) -> (f32, f32, f32); + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the x axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_x(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the y axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_y(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the z axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_z(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing the given 3D non-uniform `scale`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f32; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Creates a left-handed view matrix 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()] + fn look_to_lh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed view matrix 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()] + fn look_to_rh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a left-handed view matrix 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()] + fn look_at_lh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed view matrix 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()] + fn look_at_rh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. +/// This is the same as the OpenGL `gluPerspective` function. +/// See + + #[lua()] + fn perspective_rh_gl( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + z_far: f32, + ) -> Val; + +"#, + r#" +/// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_lh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + z_far: f32, + ) -> Val; + +"#, + r#" +/// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_rh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + z_far: f32, + ) -> Val; + +"#, + r#" +/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_infinite_lh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + ) -> Val; + +"#, + r#" +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua()] + fn perspective_infinite_reverse_lh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + ) -> Val; + +"#, + r#" +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_infinite_rh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + ) -> Val; + +"#, + r#" +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua()] + fn perspective_infinite_reverse_rh( + fov_y_radians: f32, + aspect_ratio: f32, + z_near: f32, + ) -> Val; + +"#, + r#" +/// Creates a right-handed orthographic projection matrix with `[-1,1]` depth +/// range. This is the same as the OpenGL `glOrtho` function in OpenGL. +/// See +/// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. + + #[lua()] + fn orthographic_rh_gl( + left: f32, + right: f32, + bottom: f32, + top: f32, + near: f32, + far: f32, + ) -> Val; + +"#, + r#" +/// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. + + #[lua()] + fn orthographic_lh( + left: f32, + right: f32, + bottom: f32, + top: f32, + near: f32, + far: f32, + ) -> Val; + +"#, + r#" +/// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. + + #[lua()] + fn orthographic_rh( + left: f32, + right: f32, + bottom: f32, + top: f32, + near: f32, + far: f32, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector as a point, applying perspective correction. +/// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. +/// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. +/// This method assumes that `self` contains a projective transform. + + #[lua()] + fn project_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector as a point. +/// 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 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. + + #[lua()] + fn transform_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the give 3D vector as a direction. +/// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is +/// `0.0`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_vector3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given [`Vec3A`] as a 3D point, applying perspective correction. +/// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. +/// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. +/// This method assumes that `self` contains a projective transform. + + #[lua()] + fn project_point3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given [`Vec3A`] as 3D point. +/// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. + + #[lua()] + fn transform_point3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the give [`Vec3A`] as 3D vector. +/// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `0.0`. + + #[lua()] + fn transform_vector3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a 4D vector. + + #[lua()] + fn mul_vec4( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 4x4 matrices. + + #[lua()] + fn mul_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 4x4 matrices. + + #[lua()] + fn add_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 4x4 matrices. + + #[lua()] + fn sub_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 4x4 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + r#" +/// Divides a 4x4 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f32) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f32, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_dmat4(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct Mat4 { + x_axis: bevy::math::Vec4, + y_axis: bevy::math::Vec4, + z_axis: bevy::math::Vec4, + w_axis: bevy::math::Vec4, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from two column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + ) -> Val; + +"#, + 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()] + fn to_cols_array(_self: Ref) -> [f64; 4]; + +"#, + r#" +/// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f64; 2]; 2]; + +"#, + r#" +/// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of +/// `angle` (in radians). + + #[lua()] + fn from_scale_angle( + scale: Val, + angle: f64, + ) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua()] + fn from_angle(angle: f64) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua()] + fn from_mat3_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 1. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f64; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Transforms a 2D vector. + + #[lua()] + fn mul_vec2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 2x2 matrices. + + #[lua()] + fn mul_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 2x2 matrices. + + #[lua()] + fn add_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 2x2 matrices. + + #[lua()] + fn sub_mat2( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 2x2 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + r#" +/// Divides a 2x2 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f64, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_mat2(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct DMat2 { + x_axis: bevy::math::DVec2, + y_axis: bevy::math::DVec2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f64; 9]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array(_self: Ref) -> [f64; 9]; + +"#, + r#" +/// Creates a `[[f64; 3]; 3]` 3D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f64; 3]; 3]; + +"#, + r#" +/// Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua()] + fn from_mat4(m: Val) -> Val; + +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua()] + fn from_mat4_minor( + m: Val, + i: usize, + j: usize, + ) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given quaternion. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in +/// radians). +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_axis_angle( + axis: Val, + angle: f64, + ) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in +/// radians). + + #[lua()] + fn from_euler( + order: Val, + a: f64, + b: f64, + c: f64, + ) -> Val; + +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn to_euler( + _self: Ref, + order: Val, + ) -> (f64, f64, f64); + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua()] + fn from_rotation_x(angle: f64) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua()] + fn from_rotation_y(angle: f64) -> Val; + +"#, + r#" +/// Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua()] + fn from_rotation_z(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D rotation `angle` (in +/// radians). +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_angle(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in +/// radians) and `translation`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_scale_angle_translation( + scale: Val, + angle: f64, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given non-uniform 2D `scale`. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. +/// # Panics +/// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 2x2 matrix. +/// The resulting matrix can be used to transform 2D points and vectors. See +/// [`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua()] + fn from_mat2(m: Val) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 2. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f64; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Transforms the given 2D vector as a point. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_point2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Rotates the given 2D vector. +/// This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_vector2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a 3D vector. + + #[lua()] + fn mul_vec3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 3x3 matrices. + + #[lua()] + fn mul_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 3x3 matrices. + + #[lua()] + fn add_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 3x3 matrices. + + #[lua()] + fn sub_mat3( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 3x3 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + r#" +/// Divides a 3x3 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f64, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_mat3(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct DMat3 { + x_axis: bevy::math::DVec3, + y_axis: bevy::math::DVec3, + z_axis: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DMat4", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a 4x4 matrix from four column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + w_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f64; 16]` array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array(_self: Ref) -> [f64; 16]; + +"#, + r#" +/// Creates a `[[f64; 4]; 4]` 4D array storing data in column major order. +/// If you require data in row major order `transpose` the matrix first. + + #[lua()] + fn to_cols_array_2d(_self: Ref) -> [[f64; 4]; 4]; + +"#, + r#" +/// Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua()] + fn from_diagonal(diagonal: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `scale`, `rotation` and +/// `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_scale_rotation_translation( + scale: Val, + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_rotation_translation( + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given `rotation` quaternion. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3x3 linear transformation +/// matrix. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix from the given 3D `translation`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_axis_angle( + axis: Val, + angle: f64, + ) -> Val; + +"#, + r#" +/// Creates a affine transformation matrix containing a rotation from the given euler +/// rotation sequence and angles (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_euler( + order: Val, + a: f64, + b: f64, + c: f64, + ) -> Val; + +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua()] + fn to_euler( + _self: Ref, + order: Val, + ) -> (f64, f64, f64); + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the x axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_x(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the y axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_y(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing a 3D rotation around the z axis of +/// `angle` (in radians). +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua()] + fn from_rotation_z(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation matrix containing the given 3D non-uniform `scale`. +/// The resulting matrix can be used to transform 3D points and vectors. See +/// [`Self::transform_point3()`] and [`Self::transform_vector3()`]. +/// # Panics +/// Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Returns the matrix column for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua()] + fn col(_self: Ref, index: usize) -> Val; + +"#, + r#" +/// Returns the matrix row for the given `index`. +/// # Panics +/// Panics if `index` is greater than 3. + + #[lua()] + fn row(_self: Ref, index: usize) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> bool; + +"#, + r#" +/// Returns the transpose of `self`. + + #[lua()] + fn transpose(_self: Ref) -> Val; + +"#, + r#" +/// Returns the determinant of `self`. + + #[lua()] + fn determinant(_self: Ref) -> f64; + +"#, + r#" +/// Returns the inverse of `self`. +/// If the matrix is not invertible the returned matrix will be invalid. +/// # Panics +/// Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" +/// Creates a left-handed view matrix 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()] + fn look_to_lh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed view matrix 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()] + fn look_to_rh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a left-handed view matrix 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()] + fn look_at_lh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed view matrix 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()] + fn look_at_rh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. +/// This is the same as the OpenGL `gluPerspective` function. +/// See + + #[lua()] + fn perspective_rh_gl( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + z_far: f64, + ) -> Val; + +"#, + r#" +/// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_lh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + z_far: f64, + ) -> Val; + +"#, + r#" +/// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_rh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + z_far: f64, + ) -> Val; + +"#, + r#" +/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_infinite_lh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + ) -> Val; + +"#, + r#" +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua()] + fn perspective_infinite_reverse_lh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + ) -> Val; + +"#, + r#" +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. + + #[lua()] + fn perspective_infinite_rh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + ) -> Val; + +"#, + r#" +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua()] + fn perspective_infinite_reverse_rh( + fov_y_radians: f64, + aspect_ratio: f64, + z_near: f64, + ) -> Val; + +"#, + r#" +/// Creates a right-handed orthographic projection matrix with `[-1,1]` depth +/// range. This is the same as the OpenGL `glOrtho` function in OpenGL. +/// See +/// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. + + #[lua()] + fn orthographic_rh_gl( + left: f64, + right: f64, + bottom: f64, + top: f64, + near: f64, + far: f64, + ) -> Val; + +"#, + r#" +/// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. + + #[lua()] + fn orthographic_lh( + left: f64, + right: f64, + bottom: f64, + top: f64, + near: f64, + far: f64, + ) -> Val; + +"#, + r#" +/// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. + + #[lua()] + fn orthographic_rh( + left: f64, + right: f64, + bottom: f64, + top: f64, + near: f64, + far: f64, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector as a point, applying perspective correction. +/// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. +/// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. +/// This method assumes that `self` contains a projective transform. + + #[lua()] + fn project_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector as a point. +/// 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 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. + + #[lua()] + fn transform_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the give 3D vector as a direction. +/// This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is +/// `0.0`. +/// This method assumes that `self` contains a valid affine transform. +/// # Panics +/// Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua()] + fn transform_vector3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms a 4D vector. + + #[lua()] + fn mul_vec4( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies two 4x4 matrices. + + #[lua()] + fn mul_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Adds two 4x4 matrices. + + #[lua()] + fn add_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Subtracts two 4x4 matrices. + + #[lua()] + fn sub_mat4( + _self: Ref, + rhs: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies a 4x4 matrix by a scalar. + + #[lua()] + fn mul_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + r#" +/// Divides a 4x4 matrix by a scalar. + + #[lua()] + fn div_scalar(_self: Ref, rhs: f64) -> Val; + +"#, + 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. +/// For more see +/// [comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + max_abs_diff: f64, + ) -> bool; + +"#, + r#" +/// Takes the absolute value of each element in `self` + + #[lua()] + fn abs(_self: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_mat4(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(metamethod="Index", with_context, no_proxy)] +fn index(_self: Self, idx: usize, lua: &tealr::mlu::mlua::Lua) -> Result { + let mut curr_ref = _self.0; + + let path = match idx { + 1 => "x_axis", + 2 => "y_axis", + 3 => "z_axis", + 4 => "w_axis", + _ => "unknown_axis" + }; + + let parsed_path = bevy::reflect::ParsedPath::parse_static(path).expect("invariant"); + curr_ref.index_path(bevy_mod_scripting_core::bindings::ReflectionPathElem::new_reflection(parsed_path)); + crate::bindings::reference::LuaReflectReference(curr_ref).to_lua_proxy(lua) +} +"#] +)] +pub struct DMat4 { + x_axis: bevy::math::DVec4, + y_axis: bevy::math::DVec4, + z_axis: bevy::math::DVec4, + w_axis: bevy::math::DVec4, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Affine2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f32; 6]` array storing data in column major order. + + #[lua()] + fn to_cols_array(_self: Ref) -> [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()] + fn to_cols_array_2d(_self: Ref) -> [[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()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from the given rotation `angle`. + + #[lua()] + fn from_angle(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation from the given 2D `translation`. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) + + #[lua()] + fn from_mat2(matrix2: Val) -> Val; + +"#, + 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()] + fn from_mat2_translation( + matrix2: Val, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_scale_angle_translation( + scale: Val, + angle: f32, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_angle_translation( + angle: f32, + translation: Val, + ) -> Val; + +"#, + r#" +/// The given `Mat3` must be an affine transform, + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// The given [`Mat3A`] must be an affine transform, + + #[lua()] + fn from_mat3a(m: Val) -> Val; + +"#, + r#" +/// Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua()] + fn transform_point2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point2()`] instead. + + #[lua()] + fn transform_vector2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> 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()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + 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()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Affine2 { + matrix2: bevy::math::Mat2, + translation: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::Affine3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + w_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f32; 12]` array storing data in column major order. + + #[lua()] + fn to_cols_array(_self: Ref) -> [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()] + fn to_cols_array_2d(_self: Ref) -> [[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()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from the given `rotation` quaternion. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). + + #[lua()] + fn from_axis_angle( + axis: Val, + angle: f32, + ) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the x axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_x(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the y axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_y(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the z axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_z(angle: f32) -> Val; + +"#, + r#" +/// Creates an affine transformation from the given 3D `translation`. + + #[lua()] + fn from_translation(translation: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and +/// rotation) + + #[lua()] + fn from_mat3(mat3: Val) -> Val; + +"#, + 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()] + fn from_mat3_translation( + mat3: Val, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_scale_rotation_translation( + scale: Val, + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transform from the given 3D `rotation` and `translation`. +/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)` + + #[lua()] + fn from_rotation_translation( + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// The given `Mat4` must be an affine transform, +/// i.e. contain no perspective transform. + + #[lua()] + fn from_mat4(m: Val) -> Val; + +"#, + 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()] + fn look_to_lh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_to_rh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_at_lh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_at_rh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua()] + fn transform_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3()`] instead. + + #[lua()] + fn transform_vector3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. + + #[lua()] + fn transform_point3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3a()`] instead. + + #[lua()] + fn transform_vector3a( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> 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()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + 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()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Affine3A { + matrix3: bevy::math::Mat3A, + translation: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DAffine2", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" +/// Creates an affine transform from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f64; 6]` array storing data in column major order. + + #[lua()] + fn to_cols_array(_self: Ref) -> [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()] + fn to_cols_array_2d(_self: Ref) -> [[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()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from the given rotation `angle`. + + #[lua()] + fn from_angle(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation from the given 2D `translation`. + + #[lua()] + fn from_translation( + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) + + #[lua()] + fn from_mat2(matrix2: Val) -> Val; + +"#, + 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()] + fn from_mat2_translation( + matrix2: Val, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_scale_angle_translation( + scale: Val, + angle: f64, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_angle_translation( + angle: f64, + translation: Val, + ) -> Val; + +"#, + r#" +/// The given `DMat3` must be an affine transform, + + #[lua()] + fn from_mat3(m: Val) -> Val; + +"#, + r#" +/// Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua()] + fn transform_point2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 2D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point2()`] instead. + + #[lua()] + fn transform_vector2( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> 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()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + 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()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct DAffine2 { + matrix2: bevy::math::DMat2, + translation: bevy::math::DVec2, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DAffine3", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates an affine transform from three column vectors. + + #[lua()] + fn from_cols( + x_axis: Val, + y_axis: Val, + z_axis: Val, + w_axis: Val, + ) -> Val; + +"#, + r#" +/// Creates a `[f64; 12]` array storing data in column major order. + + #[lua()] + fn to_cols_array(_self: Ref) -> [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()] + fn to_cols_array_2d(_self: Ref) -> [[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()] + fn from_scale(scale: Val) -> Val; + +"#, + r#" +/// Creates an affine transform from the given `rotation` quaternion. + + #[lua()] + fn from_quat(rotation: Val) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around a normalized +/// rotation `axis` of `angle` (in radians). + + #[lua()] + fn from_axis_angle( + axis: Val, + angle: f64, + ) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the x axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_x(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the y axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_y(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transform containing a 3D rotation around the z axis of +/// `angle` (in radians). + + #[lua()] + fn from_rotation_z(angle: f64) -> Val; + +"#, + r#" +/// Creates an affine transformation from the given 3D `translation`. + + #[lua()] + fn from_translation( + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transform from a 3x3 matrix (expressing scale, shear and +/// rotation) + + #[lua()] + fn from_mat3(mat3: Val) -> Val; + +"#, + 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()] + fn from_mat3_translation( + mat3: Val, + translation: Val, + ) -> Val; + +"#, + 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()] + fn from_scale_rotation_translation( + scale: Val, + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// Creates an affine transform from the given 3D `rotation` and `translation`. +/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)` + + #[lua()] + fn from_rotation_translation( + rotation: Val, + translation: Val, + ) -> Val; + +"#, + r#" +/// The given `DMat4` must be an affine transform, +/// i.e. contain no perspective transform. + + #[lua()] + fn from_mat4(m: Val) -> Val; + +"#, + 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()] + fn look_to_lh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_to_rh( + eye: Val, + dir: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_at_lh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + 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()] + fn look_at_rh( + eye: Val, + center: Val, + up: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua()] + fn transform_point3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Transforms the given 3D vector, applying shear, scale and rotation (but NOT +/// translation). +/// To also apply translation, use [`Self::transform_point3()`] instead. + + #[lua()] + fn transform_vector3( + _self: Ref, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NaN`. + + #[lua()] + fn is_nan(_self: Ref) -> 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()] + fn abs_diff_eq( + _self: Ref, + rhs: Val, + 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()] + fn inverse(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct DAffine3 { + matrix3: bevy::math::DMat3, + translation: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::DQuat", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua(as_trait = "std::ops::Div::", composite = "div", metamethod = "Div")] + fn div(_self: Val, rhs: f64) -> Val; + +"#, + 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()] + fn from_xyzw(x: f64, y: f64, z: f64, w: f64) -> Val; + +"#, + 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()] + fn from_array(a: [f64; 4]) -> Val; + +"#, + 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()] + fn from_vec4(v: Val) -> Val; + +"#, + 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()] + fn from_axis_angle( + axis: Val, + angle: f64, + ) -> Val; + +"#, + r#" +/// Create a quaternion that rotates `v.length()` radians around `v.normalize()`. +/// `from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. + + #[lua()] + fn from_scaled_axis(v: Val) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua()] + fn from_rotation_x(angle: f64) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua()] + fn from_rotation_y(angle: f64) -> Val; + +"#, + r#" +/// Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua()] + fn from_rotation_z(angle: f64) -> Val; + +"#, + r#" +/// Creates a quaternion from the given Euler rotation sequence and the angles (in radians). + + #[lua()] + fn from_euler( + euler: Val, + a: f64, + b: f64, + c: f64, + ) -> Val; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua()] + fn from_mat3(mat: Ref) -> Val; + +"#, + r#" +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua()] + fn from_mat4(mat: Ref) -> Val; + +"#, + 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()] + fn from_rotation_arc( + from: Val, + to: Val, + ) -> Val; + +"#, + 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()] + fn from_rotation_arc_colinear( + from: Val, + to: Val, + ) -> Val; + +"#, + 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()] + fn from_rotation_arc_2d( + from: Val, + to: Val, + ) -> Val; + +"#, + r#" +/// Returns the rotation axis scaled by the rotation in radians. + + #[lua()] + fn to_scaled_axis(_self: Val) -> Val; + +"#, + r#" +/// Returns the rotation angles for the given euler rotation sequence. + + #[lua()] + fn to_euler( + _self: Val, + order: Val, + ) -> (f64, f64, f64); + +"#, + r#" +/// `[x, y, z, w]` + + #[lua()] + fn to_array(_self: Ref) -> [f64; 4]; + +"#, + r#" +/// Returns the vector part of the quaternion. + + #[lua()] + fn xyz(_self: Val) -> Val; + +"#, + r#" +/// Returns the quaternion conjugate of `self`. For a unit quaternion the +/// conjugate is also the inverse. + + #[lua()] + fn conjugate(_self: Val) -> Val; + +"#, + 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()] + fn inverse(_self: Val) -> Val; + +"#, + 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()] + fn dot(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Computes the length of `self`. + + #[lua()] + fn length(_self: Val) -> f64; + +"#, + r#" +/// Computes the squared length of `self`. +/// This is generally faster than `length()` as it avoids a square +/// root operation. + + #[lua()] + fn length_squared(_self: Val) -> f64; + +"#, + r#" +/// Computes `1.0 / length()`. +/// For valid results, `self` must _not_ be of length zero. + + #[lua()] + fn length_recip(_self: Val) -> 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()] + fn normalize(_self: Val) -> Val; + +"#, + 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()] + fn is_finite(_self: Val) -> bool; + +"#, + r#" +/// Returns `true` if any elements are `NAN`. + + #[lua()] + fn is_nan(_self: Val) -> bool; + +"#, + r#" +/// Returns whether `self` of length `1.0` or not. +/// Uses a precision threshold of `1e-6`. + + #[lua()] + fn is_normalized(_self: Val) -> bool; + +"#, + r#" + + #[lua()] + fn is_near_identity(_self: Val) -> 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()] + fn angle_between(_self: Val, rhs: Val) -> f64; + +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua()] + fn rotate_towards( + _self: Ref, + rhs: Val, + max_angle: f64, + ) -> Val; + +"#, + 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()] + fn abs_diff_eq( + _self: Val, + rhs: Val, + 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()] + fn lerp( + _self: Val, + end: Val, + s: f64, + ) -> Val; + +"#, + 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()] + fn slerp( + _self: Val, + end: Val, + s: f64, + ) -> Val; + +"#, + 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()] + fn mul_vec3( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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()] + fn mul_quat( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. + + #[lua()] + fn from_affine3(a: Ref) -> Val; + +"#, + r#" + + #[lua()] + fn as_quat(_self: Val) -> Val; + +"#, + 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::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + 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::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub::", + composite = "sub", + metamethod = "Sub", + )] + fn sub( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua(as_trait = "std::ops::Mul::", composite = "mul", metamethod = "Mul")] + fn mul(_self: Val, rhs: f64) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::ops::Neg", composite = "neg", metamethod = "Unm")] + fn neg(_self: Val) -> Val; + +"#, + 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::", + composite = "add", + metamethod = "Add", + )] + fn add( + _self: Val, + rhs: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct DQuat { + x: f64, + y: f64, + z: f64, + w: f64, +} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::EulerRot", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct EulerRot {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec3A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new vector mask. + + #[lua()] + fn new(x: bool, y: bool, z: bool) -> Val; + +"#, + r#" +/// Creates a vector mask with all elements set to `v`. + + #[lua()] + fn splat(v: bool) -> Val; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua()] + fn from_array(a: [bool; 3]) -> Val; + +"#, + 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()] + fn bitmask(_self: Val) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua()] + fn any(_self: Val) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua()] + fn all(_self: Val) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 2. + + #[lua()] + fn test(_self: Ref, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 2. + + #[lua()] + fn set(_self: Mut, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BVec3A(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::math::BVec4A", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new vector mask. + + #[lua()] + fn new(x: bool, y: bool, z: bool, w: bool) -> Val; + +"#, + r#" +/// Creates a vector mask with all elements set to `v`. + + #[lua()] + fn splat(v: bool) -> Val; + +"#, + r#" +/// Creates a new vector mask from a bool array. + + #[lua()] + fn from_array(a: [bool; 4]) -> Val; + +"#, + 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()] + fn bitmask(_self: Val) -> u32; + +"#, + r#" +/// Returns true if any of the elements are true, false otherwise. + + #[lua()] + fn any(_self: Val) -> bool; + +"#, + r#" +/// Returns true if all the elements are true, false otherwise. + + #[lua()] + fn all(_self: Val) -> bool; + +"#, + r#" +/// Tests the value at `index`. +/// Panics if `index` is greater than 3. + + #[lua()] + fn test(_self: Ref, index: usize) -> bool; + +"#, + r#" +/// Sets the element at `index`. +/// Panics if `index` is greater than 3. + + #[lua()] + fn set(_self: Mut, index: usize, value: bool) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, rhs: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct BVec4A(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "smol_str::SmolStr", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua()] + fn to_string(_self: Ref) -> std::string::String; + +"#, + r#" + + #[lua()] + fn len(_self: Ref) -> usize; + +"#, + r#" + + #[lua()] + fn is_empty(_self: Ref) -> bool; + +"#, + r#" + + #[lua()] + fn is_heap_allocated(_self: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct SmolStr(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "uuid::Uuid", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + 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`]. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?; +/// assert_eq!(3, my_uuid.get_version_num()); +/// # Ok(()) +/// # } +/// ``` +/// # References +/// * [Version Field in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-4.2) + + #[lua()] + fn get_version_num(_self: Ref) -> usize; + +"#, + r#" +/// Returns a 128bit value containing the value. +/// The bytes in the UUID will be packed directly into a `u128`. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.as_u128(), +/// 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8, +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn as_u128(_self: Ref) -> u128; + +"#, + r#" +/// Returns a 128bit little-endian value containing the value. +/// The bytes in the `u128` will be flipped to convert into big-endian +/// order. This is based on the endianness of the UUID, rather than the +/// target environment so bytes will be flipped on both big and little +/// endian machines. +/// Note that this will produce a different result than +/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather +/// than reversing the individual fields in-place. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.to_u128_le(), +/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn to_u128_le(_self: Ref) -> u128; + +"#, + r#" +/// Returns two 64bit values containing the value. +/// The bytes in the UUID will be split into two `u64`. +/// The first u64 represents the 64 most significant bits, +/// the second one represents the 64 least significant. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.as_u64_pair(), +/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn as_u64_pair(_self: Ref) -> (u64, u64); + +"#, + r#" +/// Consumes self and returns the underlying byte value of the UUID. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes(bytes); +/// assert_eq!(bytes, uuid.into_bytes()); +/// ``` + + #[lua()] + fn into_bytes(_self: Val) -> [u8; 16]; + +"#, + r#" +/// Returns the bytes of the UUID in little-endian order. +/// The bytes will be flipped to convert into little-endian order. This is +/// based on the endianness of the UUID, rather than the target environment +/// so bytes will be flipped on both big and little endian machines. +/// # Examples +/// ``` +/// use uuid::Uuid; +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; +/// assert_eq!( +/// uuid.to_bytes_le(), +/// ([ +/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, +/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 +/// ]) +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn to_bytes_le(_self: Ref) -> [u8; 16]; + +"#, + r#" +/// Tests if the UUID is nil (all zeros). + + #[lua()] + fn is_nil(_self: Ref) -> bool; + +"#, + r#" +/// Tests if the UUID is max (all ones). + + #[lua()] + fn is_max(_self: Ref) -> bool; + +"#, + r#" +/// A buffer that can be used for `encode_...` calls, that is +/// guaranteed to be long enough for any of the format adapters. +/// # Examples +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), +/// "00000000000000000000000000000000" +/// ); +/// assert_eq!( +/// uuid.hyphenated() +/// .encode_lower(&mut Uuid::encode_buffer()), +/// "00000000-0000-0000-0000-000000000000" +/// ); +/// assert_eq!( +/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), +/// "urn:uuid:00000000-0000-0000-0000-000000000000" +/// ); +/// ``` + + #[lua()] + 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()] + fn get_node_id( + _self: Ref, + ) -> bevy::reflect::erased_serde::__private::serde::__private::Option<[u8; 6]>; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +/// The 'nil UUID' (all zeros). +/// The nil UUID is a special form of UUID that is specified to have all +/// 128 bits set to zero. +/// # References +/// * [Nil UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.9) +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// "00000000-0000-0000-0000-000000000000", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua()] + fn nil() -> Val; + +"#, + r#" +/// The 'max UUID' (all ones). +/// The max UUID is a special form of UUID that is specified to have all +/// 128 bits set to one. +/// # References +/// * [Max UUID in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.10) +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let uuid = Uuid::max(); +/// assert_eq!( +/// "ffffffff-ffff-ffff-ffff-ffffffffffff", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua()] + fn max() -> Val; + +"#, + r#" +/// Creates a UUID from a 128bit value. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128(v); +/// assert_eq!( +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua()] + fn from_u128(v: u128) -> Val; + +"#, + r#" +/// Creates a UUID from a 128bit value in little-endian order. +/// The entire value will be flipped to convert into big-endian order. +/// This is based on the endianness of the UUID, rather than the target +/// environment so bytes will be flipped on both big and little endian +/// machines. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; +/// let uuid = Uuid::from_u128_le(v); +/// assert_eq!( +/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua()] + fn from_u128_le(v: u128) -> Val; + +"#, + r#" +/// Creates a UUID from two 64bit values. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::Uuid; +/// let hi = 0xa1a2a3a4b1b2c1c2u64; +/// let lo = 0xd1d2d3d4d5d6d7d8u64; +/// let uuid = Uuid::from_u64_pair(hi, lo); +/// assert_eq!( +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// ``` + + #[lua()] + fn from_u64_pair(high_bits: u64, low_bits: u64) -> Val; + +"#, + r#" +/// Creates a UUID using the supplied bytes. +/// # Examples +/// Basic usage: +/// ``` +/// # fn main() -> Result<(), uuid::Error> { +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes(bytes); +/// assert_eq!( +/// uuid.hyphenated().to_string(), +/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn from_bytes(bytes: [u8; 16]) -> Val; + +"#, + r#" +/// Creates a UUID using the supplied bytes in little endian order. +/// The individual fields encoded in the buffer will be flipped. +/// # Examples +/// Basic usage: +/// ``` +/// # fn main() -> Result<(), uuid::Error> { +/// # use uuid::Uuid; +/// let bytes = [ +/// 0xa1, 0xa2, 0xa3, 0xa4, +/// 0xb1, 0xb2, +/// 0xc1, 0xc2, +/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, +/// ]; +/// let uuid = Uuid::from_bytes_le(bytes); +/// assert_eq!( +/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", +/// uuid.hyphenated().to_string(), +/// ); +/// # Ok(()) +/// # } +/// ``` + + #[lua()] + fn from_bytes_le(b: [u8; 16]) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" + + #[lua(as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +/// Creates a random UUID. +/// This uses the [`getrandom`] crate to utilise the operating system's RNG +/// as the source of random numbers. If you'd like to use a custom +/// generator, don't use this method: generate random bytes using your +/// custom generator and pass them to the +/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function +/// instead. +/// Note that usage of this method requires the `v4` feature of this crate +/// to be enabled. +/// # Examples +/// Basic usage: +/// ``` +/// # use uuid::{Uuid, Version}; +/// let uuid = Uuid::new_v4(); +/// assert_eq!(Some(Version::Random), uuid.get_version()); +/// ``` +/// # References +/// * [UUID Version 4 in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.4) +/// [`getrandom`]: https://crates.io/crates/getrandom +/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes + + #[lua()] + fn new_v4() -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Uuid(); +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "AtomicBool", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI16", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI32", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI64", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI8", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicIsize", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU16", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU32", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU64", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU8", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicUsize", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Duration", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Instant", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Quat", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Vec3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("IVec2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("IVec3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("IVec4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "I64Vec2", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "I64Vec3", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "I64Vec4", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("UVec2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("UVec3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("UVec4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "U64Vec2", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "U64Vec3", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "U64Vec4", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("Vec2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Vec3A", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Vec4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("BVec2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("BVec3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("BVec4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DVec2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DVec3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DVec4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Mat2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Mat3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Mat3A", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Mat4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DMat2", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DMat3", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("DMat4", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Affine2", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Affine3A", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "DAffine2", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "DAffine3", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance("DQuat", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("BVec3A", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("BVec4A", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance("Uuid", crate::tealr::mlu::UserDataProxy::::new)?; + Ok(()) + } +} +fn bevy_reflect_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyReflectScriptingPlugin; +impl bevy::app::Plugin for BevyReflectScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_reflect_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyReflectAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .process_type::() + .process_type::>() + .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::>() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_time.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_time.rs new file mode 100644 index 0000000000..55f0f2fe59 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_time.rs @@ -0,0 +1,602 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Fixed", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Fixed {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Real", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Real {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Timer", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +/// Creates a new timer with a given duration in seconds. +/// # Example +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// ``` + + #[lua()] + fn from_seconds( + duration: f32, + mode: Val, + ) -> Val; + +"#, + r#" +/// Returns `true` if the timer has reached its duration. +/// For repeating timers, this method behaves identically to [`Timer::just_finished`]. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer_once = Timer::from_seconds(1.0, TimerMode::Once); +/// timer_once.tick(Duration::from_secs_f32(1.5)); +/// assert!(timer_once.finished()); +/// timer_once.tick(Duration::from_secs_f32(0.5)); +/// assert!(timer_once.finished()); +/// let mut timer_repeating = Timer::from_seconds(1.0, TimerMode::Repeating); +/// timer_repeating.tick(Duration::from_secs_f32(1.1)); +/// assert!(timer_repeating.finished()); +/// timer_repeating.tick(Duration::from_secs_f32(0.8)); +/// assert!(!timer_repeating.finished()); +/// timer_repeating.tick(Duration::from_secs_f32(0.6)); +/// assert!(timer_repeating.finished()); +/// ``` + + #[lua()] + fn finished(_self: Ref) -> bool; + +"#, + r#" +/// Returns `true` only on the tick the timer reached its duration. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(1.5)); +/// assert!(timer.just_finished()); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert!(!timer.just_finished()); +/// ``` + + #[lua()] + fn just_finished(_self: Ref) -> bool; + +"#, + r#" +/// Returns the time elapsed on the timer as an `f32`. +/// See also [`Timer::elapsed`](Timer::elapsed). + + #[lua()] + fn elapsed_secs(_self: Ref) -> f32; + +"#, + r#" +/// Returns the time elapsed on the timer as an `f64`. +/// See also [`Timer::elapsed`](Timer::elapsed). + + #[lua()] + fn elapsed_secs_f64(_self: Ref) -> f64; + +"#, + r#" +/// Returns the mode of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); +/// assert_eq!(timer.mode(), TimerMode::Repeating); +/// ``` + + #[lua()] + fn mode( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Sets the mode of the timer. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); +/// timer.set_mode(TimerMode::Once); +/// assert_eq!(timer.mode(), TimerMode::Once); +/// ``` + + #[lua()] + fn set_mode( + _self: Mut, + mode: Val, + ) -> (); + +"#, + r#" +/// Pauses the Timer. Disables the ticking of the timer. +/// See also [`Stopwatch::pause`](Stopwatch::pause). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.pause(); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.elapsed_secs(), 0.0); +/// ``` + + #[lua()] + fn pause(_self: Mut) -> (); + +"#, + r#" +/// Unpauses the Timer. Resumes the ticking of the timer. +/// See also [`Stopwatch::unpause()`](Stopwatch::unpause). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.pause(); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// timer.unpause(); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.elapsed_secs(), 0.5); +/// ``` + + #[lua()] + fn unpause(_self: Mut) -> (); + +"#, + r#" +/// Returns `true` if the timer is paused. +/// See also [`Stopwatch::is_paused`](Stopwatch::is_paused). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// assert!(!timer.paused()); +/// timer.pause(); +/// assert!(timer.paused()); +/// timer.unpause(); +/// assert!(!timer.paused()); +/// ``` + + #[lua()] + fn paused(_self: Ref) -> bool; + +"#, + r#" +/// Resets the timer. The reset doesn't affect the `paused` state of the timer. +/// See also [`Stopwatch::reset`](Stopwatch::reset). +/// Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(1.5)); +/// timer.reset(); +/// assert!(!timer.finished()); +/// assert!(!timer.just_finished()); +/// assert_eq!(timer.elapsed_secs(), 0.0); +/// ``` + + #[lua()] + fn reset(_self: Mut) -> (); + +"#, + r#" +/// Returns the fraction of the timer elapsed time (goes from 0.0 to 1.0). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.fraction(), 0.25); +/// ``` + + #[lua()] + fn fraction(_self: Ref) -> f32; + +"#, + r#" +/// Returns the fraction of the timer remaining time (goes from 1.0 to 0.0). +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.fraction_remaining(), 0.75); +/// ``` + + #[lua()] + fn fraction_remaining(_self: Ref) -> f32; + +"#, + r#" +/// Returns the remaining time in seconds +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::cmp::Ordering; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// let result = timer.remaining_secs().total_cmp(&1.5); +/// assert_eq!(Ordering::Equal, result); +/// ``` + + #[lua()] + fn remaining_secs(_self: Ref) -> f32; + +"#, + r#" +/// Returns the number of times a repeating timer +/// finished during the last [`tick`](Timer::tick) call. +/// For non repeating-timers, this method will only ever +/// return 0 or 1. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); +/// timer.tick(Duration::from_secs_f32(6.0)); +/// assert_eq!(timer.times_finished_this_tick(), 6); +/// timer.tick(Duration::from_secs_f32(2.0)); +/// assert_eq!(timer.times_finished_this_tick(), 2); +/// timer.tick(Duration::from_secs_f32(0.5)); +/// assert_eq!(timer.times_finished_this_tick(), 0); +/// ``` + + #[lua()] + fn times_finished_this_tick(_self: Ref) -> u32; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Timer {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::TimerMode", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct TimerMode {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::prelude::Virtual", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Virtual {} +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::time::Stopwatch", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Create a new unpaused `Stopwatch` with no elapsed time. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let stopwatch = Stopwatch::new(); +/// assert_eq!(stopwatch.elapsed_secs(), 0.0); +/// assert_eq!(stopwatch.is_paused(), false); +/// ``` + + #[lua()] + fn new() -> Val; + +"#, + r#" +/// Returns the elapsed time since the last [`reset`](Stopwatch::reset) +/// of the stopwatch, in seconds. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.tick(Duration::from_secs(1)); +/// assert_eq!(stopwatch.elapsed_secs(), 1.0); +/// ``` +/// # See Also +/// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. +/// [`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. + + #[lua()] + fn elapsed_secs(_self: Ref) -> f32; + +"#, + r#" +/// Returns the elapsed time since the last [`reset`](Stopwatch::reset) +/// of the stopwatch, in seconds, as f64. +/// # See Also +/// [`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. +/// [`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` is desirable instead. + + #[lua()] + fn elapsed_secs_f64(_self: Ref) -> f64; + +"#, + r#" +/// Pauses the stopwatch. Any call to [`tick`](Stopwatch::tick) while +/// paused will not have any effect on the elapsed time. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.pause(); +/// stopwatch.tick(Duration::from_secs_f32(1.5)); +/// assert!(stopwatch.is_paused()); +/// assert_eq!(stopwatch.elapsed_secs(), 0.0); +/// ``` + + #[lua()] + fn pause(_self: Mut) -> (); + +"#, + r#" +/// Unpauses the stopwatch. Resume the effect of ticking on elapsed time. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.pause(); +/// stopwatch.tick(Duration::from_secs_f32(1.0)); +/// stopwatch.unpause(); +/// stopwatch.tick(Duration::from_secs_f32(1.0)); +/// assert!(!stopwatch.is_paused()); +/// assert_eq!(stopwatch.elapsed_secs(), 1.0); +/// ``` + + #[lua()] + fn unpause(_self: Mut) -> (); + +"#, + r#" +/// Returns `true` if the stopwatch is paused. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// let mut stopwatch = Stopwatch::new(); +/// assert!(!stopwatch.is_paused()); +/// stopwatch.pause(); +/// assert!(stopwatch.is_paused()); +/// stopwatch.unpause(); +/// assert!(!stopwatch.is_paused()); +/// ``` + + #[lua()] + fn is_paused(_self: Ref) -> bool; + +"#, + r#" +/// Resets the stopwatch. The reset doesn't affect the paused state of the stopwatch. +/// # Examples +/// ``` +/// # use bevy_time::*; +/// use std::time::Duration; +/// let mut stopwatch = Stopwatch::new(); +/// stopwatch.tick(Duration::from_secs_f32(1.5)); +/// stopwatch.reset(); +/// assert_eq!(stopwatch.elapsed_secs(), 0.0); +/// ``` + + #[lua()] + fn reset(_self: Mut) -> (); + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq")] + fn assert_receiver_is_total_eq(_self: Ref) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone(_self: Ref) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq(_self: Ref, other: Ref) -> bool; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Stopwatch {} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance("Timer", crate::tealr::mlu::UserDataProxy::::new)?; + instances + .add_instance( + "Stopwatch", + crate::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_time_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyTimeScriptingPlugin; +impl bevy::app::Plugin for BevyTimeScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_time_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyTimeAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + .process_type::() + .process_type::() + .process_type::() + .process_type::>() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/bevy_transform.rs b/crates/bevy_mod_scripting_functions/src/bevy/bevy_transform.rs new file mode 100644 index 0000000000..7d58511755 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/bevy_transform.rs @@ -0,0 +1,347 @@ +// @generated by cargo bevy-api-gen generate, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_ecs::*; +use super::bevy_reflect::*; +use super::bevy_core::*; +use super::bevy_math::*; +use super::bevy_hierarchy::*; +use bevy_mod_scripting_core::{ + AddContextInitializer, StoreDocumentation, bindings::ReflectReference, +}; +use crate::{ + bindings::proxy::{ + LuaReflectRefProxy, LuaReflectRefMutProxy, LuaReflectValProxy, LuaValProxy, + LuaIdentityProxy, + }, + type_data::RegisterLua, tealr::mlu::mlua::IntoLua, +}; +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::transform::components::GlobalTransform", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + global_transform: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + transform: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua()] + fn from_xyz( + x: f32, + y: f32, + z: f32, + ) -> Val; + +"#, + r#" +/// Returns the transformation as a [`Transform`]. +/// The transform is expected to be non-degenerate and without shearing, or the output +/// will be invalid. + + #[lua()] + fn compute_transform( + _self: Ref, + ) -> Val; + +"#, + r#" +/// Returns the [`Transform`] `self` would have if it was a child of an entity +/// with the `parent` [`GlobalTransform`]. +/// This is useful if you want to "reparent" an [`Entity`](bevy_ecs::entity::Entity). +/// Say you have an entity `e1` that you want to turn into a child of `e2`, +/// but you want `e1` to keep the same global transform, even after re-parenting. You would use: +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform, Transform}; +/// # use bevy_ecs::prelude::{Entity, Query, Component, Commands}; +/// # use bevy_hierarchy::{prelude::Parent, BuildChildren}; +/// #[derive(Component)] +/// struct ToReparent { +/// new_parent: Entity, +/// } +/// fn reparent_system( +/// mut commands: Commands, +/// mut targets: Query<(&mut Transform, Entity, &GlobalTransform, &ToReparent)>, +/// transforms: Query<&GlobalTransform>, +/// ) { +/// for (mut transform, entity, initial, to_reparent) in targets.iter_mut() { +/// if let Ok(parent_transform) = transforms.get(to_reparent.new_parent) { +/// *transform = initial.reparented_to(parent_transform); +/// commands.entity(entity) +/// .remove::() +/// .set_parent(to_reparent.new_parent); +/// } +/// } +/// } +/// ``` +/// The transform is expected to be non-degenerate and without shearing, or the output +/// will be invalid. + + #[lua()] + fn reparented_to( + _self: Ref, + parent: Ref, + ) -> Val; + +"#, + r#" +/// Multiplies `self` with `transform` component by component, returning the +/// resulting [`GlobalTransform`] + + #[lua()] + fn mul_transform( + _self: Ref, + transform: Val, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct GlobalTransform(); +#[derive(bevy_mod_scripting_derive::LuaProxy)] +#[proxy( + remote = "bevy::transform::components::Transform", + bms_core_path = "bevy_mod_scripting_core", + bms_lua_path = "crate", + functions[r#" +/// Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component +/// is used for z-ordering elements: higher `z`-value will be in front of lower +/// `z`-value. + + #[lua()] + fn from_xyz(x: f32, y: f32, z: f32) -> Val; + +"#, + r#" +/// Rotates this [`Transform`] around the `X` axis by `angle` (in radians). +/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua()] + fn rotate_x(_self: Mut, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around the `Y` axis by `angle` (in radians). +/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua()] + fn rotate_y(_self: Mut, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around the `Z` axis by `angle` (in radians). +/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua()] + fn rotate_z(_self: Mut, angle: f32) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). + + #[lua()] + fn rotate_local_x( + _self: Mut, + angle: f32, + ) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). + + #[lua()] + fn rotate_local_y( + _self: Mut, + angle: f32, + ) -> (); + +"#, + r#" +/// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). + + #[lua()] + fn rotate_local_z( + _self: Mut, + angle: f32, + ) -> (); + +"#, + r#" +/// Multiplies `self` with `transform` component by component, returning the +/// resulting [`Transform`] + + #[lua()] + fn mul_transform( + _self: Ref, + transform: Val, + ) -> Val; + +"#, + r#" +/// Returns `true` if, and only if, translation, rotation and scale all are +/// finite. If any of them contains a `NaN`, positive or negative infinity, +/// this will return `false`. + + #[lua()] + fn is_finite(_self: Ref) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq::", + composite = "eq", + metamethod = "Eq", + )] + fn eq( + _self: Ref, + other: Ref, + ) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + transform: Val, + ) -> Val; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul::", + composite = "mul", + metamethod = "Mul", + )] + fn mul( + _self: Val, + global_transform: Val, + ) -> Val; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone")] + fn clone( + _self: Ref, + ) -> Val; + +"#, + r#" +#[lua(metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +pub struct Transform { + translation: ReflectReference, + rotation: ReflectReference, + scale: ReflectReference, +} +#[derive(Default)] +pub(crate) struct Globals; +impl crate::tealr::mlu::ExportInstances for Globals { + fn add_instances<'lua, T: crate::tealr::mlu::InstanceCollector<'lua>>( + self, + instances: &mut T, + ) -> crate::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "GlobalTransform", + crate::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Transform", + crate::tealr::mlu::UserDataProxy::::new, + )?; + Ok(()) + } +} +fn bevy_transform_context_initializer( + _: &bevy_mod_scripting_core::script::ScriptId, + ctx: &mut crate::prelude::Lua, +) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + crate::tealr::mlu::set_global_env(Globals, ctx)?; + Ok(()) +} +pub struct BevyTransformScriptingPlugin; +impl bevy::app::Plugin for BevyTransformScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.register_lua_proxy::(); + app.register_lua_proxy::(); + app.add_context_initializer::<()>(bevy_transform_context_initializer); + app.add_documentation_fragment( + crate::docs::LuaDocumentationFragment::new( + "BevyTransformAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + crate::tealr::mlu::UserDataProxy, + >() + .process_type::() + .process_type::>() + }, + ), + ); + } +} diff --git a/crates/bevy_mod_scripting_functions/src/bevy/mod.rs b/crates/bevy_mod_scripting_functions/src/bevy/mod.rs new file mode 100644 index 0000000000..94eef83506 --- /dev/null +++ b/crates/bevy_mod_scripting_functions/src/bevy/mod.rs @@ -0,0 +1,25 @@ +// @generated by cargo bevy-api-gen collect, modify the templates not this file +#![allow(clippy::all)] +#![allow(unused, deprecated, dead_code)] +#![cfg_attr(rustfmt, rustfmt_skip)] +pub mod bevy_reflect; +pub mod bevy_math; +pub mod bevy_input; +pub mod bevy_transform; +pub mod bevy_core; +pub mod bevy_hierarchy; +pub mod bevy_ecs; +pub mod bevy_time; +pub struct LuaBevyScriptingPlugin; +impl bevy::app::Plugin for LuaBevyScriptingPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + bevy_reflect::BevyReflectScriptingPlugin.build(app); + bevy_math::BevyMathScriptingPlugin.build(app); + bevy_input::BevyInputScriptingPlugin.build(app); + bevy_transform::BevyTransformScriptingPlugin.build(app); + bevy_core::BevyCoreScriptingPlugin.build(app); + bevy_hierarchy::BevyHierarchyScriptingPlugin.build(app); + bevy_ecs::BevyEcsScriptingPlugin.build(app); + bevy_time::BevyTimeScriptingPlugin.build(app); + } +}