From eff416d42367dad8d405a8ac34584088cc4f582d Mon Sep 17 00:00:00 2001 From: makspll Date: Tue, 5 Nov 2024 21:08:32 +0000 Subject: [PATCH 01/15] bump bevy to 0.15.0-rc.2 --- Cargo.toml | 2 +- crates/macro_tests/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a9b42fa..2902d741 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ bevy_script_api = { path = "crates/bevy_script_api", version = "0.7.1", optional [workspace.dependencies] -bevy = { version = "0.14.2", default-features = false } +bevy = { version = "0.15.0-rc.2", default-features = false } bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.7.1" } bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.7.1" } diff --git a/crates/macro_tests/Cargo.toml b/crates/macro_tests/Cargo.toml index 969de9f5..dd5a02b4 100644 --- a/crates/macro_tests/Cargo.toml +++ b/crates/macro_tests/Cargo.toml @@ -15,7 +15,7 @@ debug = false [dev-dependencies] trybuild = "1.0" -bevy = { version = "0.14", default-features = false } +bevy = { version = "0.15", default-features = false } bevy_mod_scripting = { path = "../../", features = [ "lua", "lua_script_api", From a2d5c4e0d5e609cb6f586f807680d1b39d218ccf Mon Sep 17 00:00:00 2001 From: makspll Date: Tue, 5 Nov 2024 21:15:35 +0000 Subject: [PATCH 02/15] migrate asset loaders --- .../bevy_mod_scripting_lua/src/assets.rs | 28 ++++++++----------- .../bevy_mod_scripting_rhai/src/assets.rs | 10 +++---- .../bevy_mod_scripting_rune/src/assets.rs | 25 ++++++----------- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index 2b87fcdf..e3043196 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -130,24 +130,20 @@ impl AssetLoader for LuaLoader { type Settings = (); type Error = Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, //bytes: &'a [u8], - _settings: &'a (), - load_context: &'a mut bevy::asset::LoadContext, - ) -> impl bevy::utils::ConditionalSendFuture< - Output = std::result::Result< - ::Asset, - ::Error, - >, + async fn load( + &self, + reader: &mut dyn Reader, //bytes: &'a [u8], + _settings: &(), + load_context: &mut bevy::asset::LoadContext<'_>, + ) -> std::result::Result< + ::Asset, + ::Error, > { bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - let bytes = old_lua_load(bytes.as_slice(), load_context).await?; - Ok(LuaFile { bytes }) //}) - }) + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + let bytes = old_lua_load(bytes.as_slice(), load_context).await?; + Ok(LuaFile { bytes }) } #[cfg(feature = "teal")] diff --git a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs index c4d2da90..5d3c82e2 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs @@ -25,11 +25,11 @@ impl AssetLoader for RhaiLoader { type Asset = RhaiFile; type Settings = (); type Error = anyhow::Error; - async fn load<'a>( - &'a self, - reader: &'a mut Reader<'_>, - _: &'a Self::Settings, - _: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _: &Self::Settings, + _: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs index e0527227..d1672849 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/assets.rs @@ -27,22 +27,15 @@ impl AssetLoader for RuneLoader { type Settings = (); type Error = Error; - fn load<'a>( - &'a self, - reader: &'a mut Reader, - _settings: &'a (), - _load_context: &'a mut bevy::asset::LoadContext, - ) -> impl bevy::utils::ConditionalSendFuture< - Output = std::result::Result< - ::Asset, - ::Error, - >, - > { - Box::pin(async move { - let mut bytes = Vec::new(); - reader.read_to_end(&mut bytes).await?; - Ok(RuneFile { bytes }) - }) + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut bevy::asset::LoadContext<'_>, + ) -> std::result::Result { + let mut bytes = Vec::new(); + reader.read_to_end(&mut bytes).await?; + Ok(RuneFile { bytes }) } fn extensions(&self) -> &[&str] { From 68d8477e34d1bab164ae3cf54a3a065e0fd61e82 Mon Sep 17 00:00:00 2001 From: makspll Date: Tue, 5 Nov 2024 22:55:58 +0000 Subject: [PATCH 03/15] Upgrade reflection API's --- crates/bevy_script_api/src/common/bevy/mod.rs | 33 ++-- crates/bevy_script_api/src/common/std.rs | 8 +- crates/bevy_script_api/src/lua/bevy/mod.rs | 6 +- crates/bevy_script_api/src/lua/std.rs | 8 +- crates/bevy_script_api/src/lua/util.rs | 63 +++++-- crates/bevy_script_api/src/rhai/std.rs | 20 ++- crates/bevy_script_api/src/sub_reflect.rs | 155 ++++++++++-------- makefile | 4 +- 8 files changed, 180 insertions(+), 117 deletions(-) diff --git a/crates/bevy_script_api/src/common/bevy/mod.rs b/crates/bevy_script_api/src/common/bevy/mod.rs index ba45a35b..56dbc87e 100644 --- a/crates/bevy_script_api/src/common/bevy/mod.rs +++ b/crates/bevy_script_api/src/common/bevy/mod.rs @@ -7,12 +7,12 @@ use bevy::{ world::{Command, EntityRef, World}, }, prelude::{ - AppTypeRegistry, BuildWorldChildren, Children, DespawnChildrenRecursive, DespawnRecursive, + AppTypeRegistry, BuildChildren, Children, DespawnChildrenRecursive, DespawnRecursive, Entity, Parent, ReflectComponent, ReflectDefault, ReflectResource, }, reflect::{ - DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple, - DynamicTupleStruct, TypeRegistration, + DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicSet, DynamicStruct, + DynamicTuple, DynamicTupleStruct, TypeRegistration, }, }; use bevy_mod_scripting_core::{prelude::ScriptError, world::WorldPointer}; @@ -169,15 +169,15 @@ impl ScriptWorld { pub fn push_child(&self, parent: Entity, child: Entity) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { - entity.push_children(&[child]); + if let Ok(mut entity) = w.get_entity_mut(parent) { + entity.add_children(&[child]); } } pub fn remove_children(&self, parent: Entity, children: &[Entity]) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { + if let Ok(mut entity) = w.get_entity_mut(parent) { entity.remove_children(children); } } @@ -185,19 +185,19 @@ impl ScriptWorld { pub fn insert_children(&self, parent: Entity, index: usize, children: &[Entity]) { let mut w = self.write(); - if let Some(mut entity) = w.get_entity_mut(parent) { + if let Ok(mut entity) = w.get_entity_mut(parent) { entity.insert_children(index, children); } } pub fn despawn_children_recursive(&self, entity: Entity) { let mut w = self.write(); - DespawnChildrenRecursive { entity }.apply(&mut w); + DespawnChildrenRecursive { entity, warn: true }.apply(&mut w); } pub fn despawn_recursive(&self, entity: Entity) { let mut w = self.write(); - DespawnRecursive { entity }.apply(&mut w); + DespawnRecursive { entity, warn: true }.apply(&mut w); } pub fn get_type_by_name(&self, type_name: &str) -> Option { @@ -225,7 +225,7 @@ impl ScriptWorld { let mut entity_ref = w .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) @@ -243,13 +243,14 @@ impl ScriptWorld { bevy::reflect::TypeInfo::List(_) => component_data.insert(&mut entity_ref, &DynamicList::default(), ®istry_lock), bevy::reflect::TypeInfo::Array(_) => component_data.insert(&mut entity_ref, &DynamicArray::new(Box::new([])), ®istry_lock), bevy::reflect::TypeInfo::Map(_) => component_data.insert(&mut entity_ref, &DynamicMap::default(), ®istry_lock), - bevy::reflect::TypeInfo::Value(_) => component_data.insert(&mut entity_ref, + bevy::reflect::TypeInfo::Set(set_info) => component_data.insert(&mut entity_ref, &DynamicSet::default(), ®istry_lock), + bevy::reflect::TypeInfo::Opaque(_) => component_data.insert(&mut entity_ref, comp_type.data::().ok_or_else(|| ScriptError::Other(format!("Component {} is a value or dynamic type with no `ReflectDefault` type_data, cannot instantiate sensible value",comp_type.short_name())))? .default() - .as_ref(), + .as_partial_reflect(), ®istry_lock), - bevy::reflect::TypeInfo::Enum(_) => component_data.insert(&mut entity_ref, &DynamicEnum::default(), ®istry_lock) + bevy::reflect::TypeInfo::Enum(_) => component_data.insert(&mut entity_ref, &DynamicEnum::default(), ®istry_lock), }; // if we do not drop the lock here, line below will complain registry is still borrowed at drop drop(registry_lock); @@ -273,7 +274,7 @@ impl ScriptWorld { let entity_ref = w .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) @@ -296,7 +297,7 @@ impl ScriptWorld { let entity_ref = w .get_entity(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; Ok(component_data.reflect(entity_ref).is_some()) } @@ -310,7 +311,7 @@ impl ScriptWorld { let mut entity_ref = w .get_entity_mut(entity) - .ok_or_else(|| ScriptError::Other(format!("Entity is not valid {:#?}", entity)))?; + .map_err(|e| ScriptError::Other(format!("Entity is not valid {:#?}. {e}", entity)))?; let component_data = comp_type.data::().ok_or_else(|| { ScriptError::Other(format!("Not a component {}", comp_type.short_name())) diff --git a/crates/bevy_script_api/src/common/std.rs b/crates/bevy_script_api/src/common/std.rs index 0f4c929c..f3da1234 100644 --- a/crates/bevy_script_api/src/common/std.rs +++ b/crates/bevy_script_api/src/common/std.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use bevy::reflect::{FromReflect, GetTypeRegistration, TypePath}; +use bevy::reflect::{FromReflect, GetTypeRegistration, TypePath, Typed}; use crate::{error::ReflectionError, ReflectReference, ValueIndex}; @@ -26,7 +26,7 @@ impl std::fmt::Debug for ScriptVec { } } -impl std::fmt::Display +impl std::fmt::Display for ScriptVec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -41,7 +41,7 @@ impl std::f } } -impl ScriptVec { +impl ScriptVec { pub fn new_ref(ref_: ReflectReference) -> Self { Self { ref_, @@ -118,7 +118,7 @@ impl Iterator for ScriptVecIterator { } } -impl IntoIterator for ScriptVec { +impl IntoIterator for ScriptVec { type Item = ReflectReference; type IntoIter = ScriptVecIterator; diff --git a/crates/bevy_script_api/src/lua/bevy/mod.rs b/crates/bevy_script_api/src/lua/bevy/mod.rs index 8b2068b2..54715102 100644 --- a/crates/bevy_script_api/src/lua/bevy/mod.rs +++ b/crates/bevy_script_api/src/lua/bevy/mod.rs @@ -9,7 +9,7 @@ use crate::lua::{ }; use crate::providers::bevy_ecs::LuaEntity; use crate::{impl_from_lua_with_clone, impl_tealr_type}; -use bevy::hierarchy::BuildWorldChildren; +use bevy::hierarchy::BuildChildren; use bevy::prelude::{AppTypeRegistry, ReflectResource}; use bevy_mod_scripting_core::prelude::*; use bevy_mod_scripting_lua::{prelude::IntoLua, tealr}; @@ -288,8 +288,8 @@ impl TealData for LuaWorld { .map(|e| e.inner()) .collect::, _>>()?; - if let Some(mut entity) = w.get_entity_mut(parent.inner()?) { - entity.push_children(&children); + if let Ok(mut entity) = w.get_entity_mut(parent.inner()?) { + entity.add_children(&children); } Ok(()) diff --git a/crates/bevy_script_api/src/lua/std.rs b/crates/bevy_script_api/src/lua/std.rs index 6dddbe93..945b4c16 100644 --- a/crates/bevy_script_api/src/lua/std.rs +++ b/crates/bevy_script_api/src/lua/std.rs @@ -106,7 +106,8 @@ impl< + GetTypeRegistration + TypePath + for<'a> FromLuaProxy<'a> - + Clone, + + Clone + + bevy::reflect::Typed, > LuaProxyable for Option { fn ref_to_lua(self_: ReflectReference, lua: &Lua) -> mlua::Result { @@ -246,6 +247,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -274,6 +276,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -294,6 +297,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a>, > TealData for LuaVec @@ -384,6 +388,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + for<'a> FromLuaProxy<'a> + for<'a> IntoLuaProxy<'a> + std::fmt::Debug, @@ -446,6 +451,7 @@ impl< + GetTypeRegistration + TypePath + LuaProxyable + + bevy::reflect::Typed + std::fmt::Debug, > FromLuaProxy<'lua> for Vec { diff --git a/crates/bevy_script_api/src/lua/util.rs b/crates/bevy_script_api/src/lua/util.rs index 2a96a3e5..f6467a57 100644 --- a/crates/bevy_script_api/src/lua/util.rs +++ b/crates/bevy_script_api/src/lua/util.rs @@ -287,6 +287,12 @@ macro_rules! impl_tealr_generic{ } + impl ::bevy::reflect::Typed for $name { + fn type_info() -> &'static ::bevy::reflect::TypeInfo { + panic!("This should never be called, I am a dummy implementation") + } + } + impl ::bevy::reflect::TypePath for $name { fn short_type_path() -> &'static str{ panic!("This should never be called, I am a dummy implementation") @@ -297,69 +303,94 @@ macro_rules! impl_tealr_generic{ } } - impl ::bevy::reflect::Reflect for $name { - fn try_apply(&mut self, _: &(dyn bevy::prelude::Reflect + 'static)) -> std::result::Result<(), bevy::reflect::ApplyError> { + impl ::bevy::reflect::PartialReflect for $name { + fn get_represented_type_info(&self) -> std::option::Option<&'static bevy::reflect::TypeInfo> { panic!("This should never be called, I am a dummy implementation"); } - fn into_any(self: Box) -> Box { + fn into_partial_reflect(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } - fn as_any(&self) -> &dyn std::any::Any { + fn as_partial_reflect(&self) -> &dyn ::bevy::reflect::PartialReflect { panic!("This should never be called, I am a dummy implementation"); } - fn as_any_mut(&mut self) -> &mut dyn std::any::Any { + fn as_partial_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::PartialReflect { panic!("This should never be called, I am a dummy implementation"); } - fn as_reflect(&self) -> &dyn ::bevy::reflect::Reflect { + fn try_into_reflect(self: Box) -> std::result::Result, std::boxed::Box<(dyn bevy::prelude::PartialReflect + 'static)>> { panic!("This should never be called, I am a dummy implementation"); } - fn as_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::Reflect { + fn try_as_reflect(&self) -> std::option::Option<&(dyn bevy::prelude::Reflect + 'static)> { panic!("This should never be called, I am a dummy implementation"); } - fn apply(&mut self, _: &dyn ::bevy::reflect::Reflect) { + fn try_as_reflect_mut(&mut self) -> std::option::Option<&mut (dyn bevy::prelude::Reflect + 'static)> { panic!("This should never be called, I am a dummy implementation"); } - fn set(&mut self, _: Box) -> Result<(), Box> { + fn try_apply(&mut self, value: &dyn ::bevy::prelude::PartialReflect) -> std::result::Result<(), ::bevy::reflect::ApplyError> { panic!("This should never be called, I am a dummy implementation"); } - fn reflect_ref(&self) -> bevy::reflect::ReflectRef { + fn reflect_ref(&self) -> ::bevy::reflect::ReflectRef { panic!("This should never be called, I am a dummy implementation"); } - fn reflect_mut(&mut self) -> bevy::reflect::ReflectMut { + fn reflect_mut(&mut self) -> ::bevy::reflect::ReflectMut { panic!("This should never be called, I am a dummy implementation"); } - fn clone_value(&self) -> Box { + fn reflect_owned(self: Box) -> ::bevy::reflect::ReflectOwned { panic!("This should never be called, I am a dummy implementation"); } - fn into_reflect(self: Box) -> Box { + fn clone_value(&self) -> Box { panic!("This should never be called, I am a dummy implementation"); } + } - fn reflect_owned(self: Box) -> ::bevy::reflect::ReflectOwned { + + impl ::bevy::reflect::Reflect for $name { + + fn into_any(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } - fn get_represented_type_info(&self) -> std::option::Option<&'static bevy::reflect::TypeInfo> { + fn as_any(&self) -> &dyn std::any::Any { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_any_mut(&mut self) -> &mut dyn std::any::Any { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_reflect(&self) -> &dyn ::bevy::reflect::Reflect { + panic!("This should never be called, I am a dummy implementation"); + } + + fn as_reflect_mut(&mut self) -> &mut dyn ::bevy::reflect::Reflect { + panic!("This should never be called, I am a dummy implementation"); + } + + fn set(&mut self, _: Box) -> Result<(), Box> { + panic!("This should never be called, I am a dummy implementation"); + } + + fn into_reflect(self: Box) -> Box { panic!("This should never be called, I am a dummy implementation"); } } impl ::bevy::reflect::FromReflect for $name { - fn from_reflect(_: &(dyn bevy::prelude::Reflect + 'static)) -> std::option::Option { + fn from_reflect(_: &(dyn bevy::prelude::PartialReflect + 'static)) -> std::option::Option { panic!("This should never be called, I am a dummy implementation"); } + } impl ::bevy::reflect::GetTypeRegistration for $name { diff --git a/crates/bevy_script_api/src/rhai/std.rs b/crates/bevy_script_api/src/rhai/std.rs index 0ed09d8c..88e8dc5d 100644 --- a/crates/bevy_script_api/src/rhai/std.rs +++ b/crates/bevy_script_api/src/rhai/std.rs @@ -121,6 +121,7 @@ impl< + TypePath + Clone + FromRhaiProxy + + bevy::reflect::Typed + GetTypeRegistration, > RhaiProxyable for Option { @@ -249,11 +250,24 @@ impl ToRhaiProxy for Option { /// Composite trait composing the various traits required for a type `T` to be used as part of a RhaiVec pub trait RhaiVecElem: - FromReflect + GetTypeRegistration + TypePath + RhaiProxyable + FromRhaiProxy + Clone + FromReflect + + GetTypeRegistration + + TypePath + + RhaiProxyable + + FromRhaiProxy + + Clone + + bevy::reflect::Typed { } -impl - RhaiVecElem for T +impl< + T: FromReflect + + GetTypeRegistration + + TypePath + + RhaiProxyable + + FromRhaiProxy + + Clone + + bevy::reflect::Typed, + > RhaiVecElem for T { } diff --git a/crates/bevy_script_api/src/sub_reflect.rs b/crates/bevy_script_api/src/sub_reflect.rs index 9ec23952..ec1d14d4 100644 --- a/crates/bevy_script_api/src/sub_reflect.rs +++ b/crates/bevy_script_api/src/sub_reflect.rs @@ -1,3 +1,4 @@ +use bevy::reflect::PartialReflect; use parking_lot::RwLock; use std::fmt; use std::fmt::{Debug, Display}; @@ -122,47 +123,52 @@ impl ReflectionPathElement { match self { ReflectionPathElement::SubReflection { get, .. } => get(base), ReflectionPathElement::FieldAccess(field) => match base.reflect_ref() { - ReflectRef::Struct(s) => { - s.field(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } + ReflectRef::Struct(s) => s + .field(field) + .map(PartialReflect::try_as_reflect) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such field".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), }), }, ReflectionPathElement::IndexAccess(index) => match base.reflect_ref() { - ReflectRef::TupleStruct(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Tuple(s) => { - s.field(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::List(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectRef::Array(s) => { - s.get(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } + ReflectRef::TupleStruct(s) => s + .field(*index) + .map(PartialReflect::try_as_reflect) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::Tuple(s) => s + .field(*index) + .map(PartialReflect::try_as_reflect) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::List(s) => s + .get(*index) + .map(PartialReflect::try_as_reflect) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectRef::Array(s) => s + .get(*index) + .map(PartialReflect::try_as_reflect) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), @@ -178,47 +184,52 @@ impl ReflectionPathElement { match self { ReflectionPathElement::SubReflection { get_mut, .. } => get_mut(base), ReflectionPathElement::FieldAccess(field) => match base.reflect_mut() { - ReflectMut::Struct(s) => { - s.field_mut(field) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such field".to_owned(), - }) - } + ReflectMut::Struct(s) => s + .field_mut(field) + .map(PartialReflect::try_as_reflect_mut) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such field".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), }), }, ReflectionPathElement::IndexAccess(index) => match base.reflect_mut() { - ReflectMut::TupleStruct(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Tuple(s) => { - s.field_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::List(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } - ReflectMut::Array(s) => { - s.get_mut(*index) - .ok_or_else(|| ReflectionError::InvalidReflectionPath { - path: self.to_string(), - msg: "No such element".to_owned(), - }) - } + ReflectMut::TupleStruct(s) => s + .field_mut(*index) + .map(PartialReflect::try_as_reflect_mut) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::Tuple(s) => s + .field_mut(*index) + .map(PartialReflect::try_as_reflect_mut) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::List(s) => s + .get_mut(*index) + .map(PartialReflect::try_as_reflect_mut) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), + ReflectMut::Array(s) => s + .get_mut(*index) + .map(PartialReflect::try_as_reflect_mut) + .flatten() + .ok_or_else(|| ReflectionError::InvalidReflectionPath { + path: self.to_string(), + msg: "No such element".to_owned(), + }), _ => Err(ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), @@ -310,9 +321,9 @@ impl ReflectionPath { let entity_ref = g.get_entity(*entity) - .ok_or_else(|| ReflectionError::InvalidBaseReference { + .map_err(|e| ReflectionError::InvalidBaseReference { base: self.base.to_string(), - reason: "This entity does not exist".to_owned(), + reason: format!("This entity could not be retrieved. {e}"), })?; let ref_ = self.walk_path(comp.reflect(entity_ref).ok_or_else(|| { diff --git a/makefile b/makefile index 74ed9a9f..acd004c3 100644 --- a/makefile +++ b/makefile @@ -22,8 +22,8 @@ TEST_NAME= # # valgrind outputs a callgrind.out.. We can analyze this with kcachegrind # kcachegrind NIGHTLY_VERSION=nightly-2024-05-20 -BEVY_VERSION=0.14.2 -GLAM_VERSION=0.28.0 +BEVY_VERSION=0.15.0-rc.2 +GLAM_VERSION=0.29.0 CODEGEN_PATH=${PWD}/target/codegen BEVY_PATH=${CODEGEN_PATH}/bevy GLAM_PATH=${CODEGEN_PATH}/glam From e3eddfe214ceb6895cbc8d445d249c6e12e96618 Mon Sep 17 00:00:00 2001 From: makspll Date: Wed, 6 Nov 2024 22:26:40 +0000 Subject: [PATCH 04/15] bump codegen & codegen new files --- .github/workflows/bevy_api_gen.yml | 10 +++++----- .github/workflows/release-plz.yml | 2 +- check.sh | 2 +- crates/bevy_api_gen/Cargo.toml | 5 ++--- crates/bevy_api_gen/readme.md | 14 +++++++------- crates/bevy_api_gen/rust-toolchain.toml | 2 +- crates/bevy_api_gen/src/bin/driver.rs | 1 + crates/bevy_api_gen/src/bin/main.rs | 1 + crates/bevy_api_gen/src/lib.rs | 4 +--- crates/bevy_api_gen/src/modifying_file_loader.rs | 8 ++++++-- crates/bevy_api_gen/src/passes/cache_traits.rs | 11 ++++++----- .../src/passes/find_methods_and_fields.rs | 7 ++++--- crates/bevy_api_gen/src/passes/find_trait_impls.rs | 4 ++-- makefile | 6 +++--- 14 files changed, 41 insertions(+), 36 deletions(-) diff --git a/.github/workflows/bevy_api_gen.yml b/.github/workflows/bevy_api_gen.yml index 02412717..1d7c7c05 100644 --- a/.github/workflows/bevy_api_gen.yml +++ b/.github/workflows/bevy_api_gen.yml @@ -27,7 +27,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -54,7 +54,7 @@ jobs: with: profile: minimal components: rustfmt - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -77,7 +77,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 components: clippy override: true - name: Rust Cache @@ -100,7 +100,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 @@ -122,7 +122,7 @@ jobs: rm -rf crates - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 68d9f987..953195c0 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -50,7 +50,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2024-05-20 + toolchain: nightly-2024-11-05 override: true working-directory: crates/bevy_api_gen - name: Install Rust toolchain diff --git a/check.sh b/check.sh index c731dd4c..eb7a8f54 100755 --- a/check.sh +++ b/check.sh @@ -4,7 +4,7 @@ CURRENT_DIR=$(basename "$PWD") if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then - cargo +nightly-2024-05-20 clippy --all-targets --message-format=json + cargo +nightly-2024-11-05 clippy --all-targets --message-format=json else cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi_threaded" fi diff --git a/crates/bevy_api_gen/Cargo.toml b/crates/bevy_api_gen/Cargo.toml index 8a06e6f3..b286f45d 100644 --- a/crates/bevy_api_gen/Cargo.toml +++ b/crates/bevy_api_gen/Cargo.toml @@ -37,17 +37,16 @@ source = "discover" rustc_private = true [rust-analyzer.check] -overrideCommand = ["cargo", "+nightly-2024-05-20", "a", "--message-format=json"] +overrideCommand = ["cargo", "+nightly-2024-11-05", "a", "--message-format=json"] [dependencies] log = "0.4" env_logger = "0.11" -rustc_plugin = "=0.10.0-nightly-2024-05-20" +rustc_plugin = { path = "../../../rustc_plugin/crates/rustc_plugin" } indexmap = "2" tempdir = "0.3" cargo_metadata = "0.18" -rustc_data_structures = "0.0.1" serde_json = "1" serde = "1" clap = { version = "4", features = ["derive", "string"] } diff --git a/crates/bevy_api_gen/readme.md b/crates/bevy_api_gen/readme.md index d8fe50e5..93f556bb 100644 --- a/crates/bevy_api_gen/readme.md +++ b/crates/bevy_api_gen/readme.md @@ -8,7 +8,7 @@ bevy_api_gen is a Cargo plugin that generates reflection-powered wrappers for Be To install bevy_api_gen, use the following command: ```bash -cargo +nightly-2024-05-20 install bevy_api_gen +cargo +nightly-2024-11-05 install bevy_api_gen ``` # Usage @@ -18,17 +18,17 @@ cargo +nightly-2024-05-20 install bevy_api_gen To run the main codegen process, use the following command: ```bash -cargo +nightly-2024-05-20 bevy-api-gen generate +cargo +nightly-2024-11-05 bevy-api-gen generate ``` -This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-05-20/bevy_api_gen` directory +This will perform all parts of the process and generate meta as well as .rs files for each crate in your workspace in your `/target/plugin-nightly-2024-11-05/bevy_api_gen` directory ## Collect After generating all the files, you can 'collect' them in a mod.rs file like so: ```bash -cargo +nightly-2024-05-20 bevy-api-gen collect +cargo +nightly-2024-11-05 bevy-api-gen collect ``` ## List Types @@ -36,7 +36,7 @@ cargo +nightly-2024-05-20 bevy-api-gen collect To see a list of all `Reflect` implementing types in your workspace run: ```bash -cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt +cargo +nightly-2024-11-05 bevy-api-gen list-types > all_types.txt ``` ## List Templates @@ -44,7 +44,7 @@ cargo +nightly-2024-05-20 bevy-api-gen list-types > all_types.txt To see the list of all templates which you can override use: ```bash -cargo +nightly-2024-05-20 bevy-api-gen list-templates +cargo +nightly-2024-11-05 bevy-api-gen list-templates ``` ## Print Template @@ -52,5 +52,5 @@ cargo +nightly-2024-05-20 bevy-api-gen list-templates You can also print any of the templates to stdout: ```bash -cargo +nightly-2024-05-20 bevy-api-gen print item.tera +cargo +nightly-2024-11-05 bevy-api-gen print item.tera ``` \ No newline at end of file diff --git a/crates/bevy_api_gen/rust-toolchain.toml b/crates/bevy_api_gen/rust-toolchain.toml index 2a12ab9a..0d5ae08d 100644 --- a/crates/bevy_api_gen/rust-toolchain.toml +++ b/crates/bevy_api_gen/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] components = ["clippy", "rust-src", "rustc-dev", "llvm-tools"] -channel = "nightly-2024-05-20" +channel = "nightly-2024-11-05" diff --git a/crates/bevy_api_gen/src/bin/driver.rs b/crates/bevy_api_gen/src/bin/driver.rs index 0136073b..492f0673 100644 --- a/crates/bevy_api_gen/src/bin/driver.rs +++ b/crates/bevy_api_gen/src/bin/driver.rs @@ -1,3 +1,4 @@ +#![feature(rustc_private)] use bevy_api_gen::*; fn main() { diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 626e1169..658afed6 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -1,3 +1,4 @@ +#![feature(rustc_private)] use std::{ collections::HashMap, env, diff --git a/crates/bevy_api_gen/src/lib.rs b/crates/bevy_api_gen/src/lib.rs index f16b9bee..23d29403 100644 --- a/crates/bevy_api_gen/src/lib.rs +++ b/crates/bevy_api_gen/src/lib.rs @@ -1,15 +1,13 @@ #![feature(rustc_private, let_chains)] #![deny(rustc::internal)] + extern crate rustc_ast; extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_hir; -extern crate rustc_hir_analysis; extern crate rustc_infer; extern crate rustc_interface; -extern crate rustc_lint; extern crate rustc_middle; -extern crate rustc_session; extern crate rustc_span; extern crate rustc_trait_selection; diff --git a/crates/bevy_api_gen/src/modifying_file_loader.rs b/crates/bevy_api_gen/src/modifying_file_loader.rs index a8c01d85..7fab22dd 100644 --- a/crates/bevy_api_gen/src/modifying_file_loader.rs +++ b/crates/bevy_api_gen/src/modifying_file_loader.rs @@ -1,7 +1,11 @@ -use std::io; +use std::{ + io, + sync::atomic::{AtomicBool, Ordering}, +}; use log::trace; -use rustc_data_structures::sync::{AtomicBool, Lrc, Ordering}; +use rustc_middle::ty::data_structures::Lrc; +// use rustc_data_structures::sync::{AtomicBool, Lrc}; use rustc_span::source_map::{FileLoader, RealFileLoader}; /// Injects extern statements into the first loaded file (crate root) diff --git a/crates/bevy_api_gen/src/passes/cache_traits.rs b/crates/bevy_api_gen/src/passes/cache_traits.rs index bdbd9568..12e2972b 100644 --- a/crates/bevy_api_gen/src/passes/cache_traits.rs +++ b/crates/bevy_api_gen/src/passes/cache_traits.rs @@ -66,11 +66,12 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool { .join(", ") ); - panic!( - "Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?", - ctxt.cached_traits.missing_std_source_traits().join(", "), - tcx.crate_name(LOCAL_CRATE) - ) + // TODO: figure out why some crates are missing std::fmt::Display etc + // panic!( + // "Could not find traits: [{}] in crate: {}, did bootstrapping go wrong?", + // ctxt.cached_traits.missing_std_source_traits().join(", "), + // tcx.crate_name(LOCAL_CRATE) + // ) } true diff --git a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs index ab016de1..20e4cec9 100644 --- a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs +++ b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs @@ -6,7 +6,9 @@ use rustc_hir::{ Safety, }; use rustc_infer::infer::TyCtxtInferExt; -use rustc_middle::ty::{AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind}; +use rustc_middle::ty::{ + AdtKind, AssocKind, FieldDef, FnSig, ParamEnv, Ty, TyCtxt, TyKind, TypingMode, +}; use rustc_span::Symbol; use rustc_trait_selection::infer::InferCtxtExt; @@ -86,7 +88,6 @@ pub(crate) fn find_methods_and_fields(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> let mut all_impls = ctxt .tcx .inherent_impls(def_id) - .unwrap() .iter() .chain(trait_impls_for_ty.iter().flatten()) .collect::>(); @@ -410,7 +411,7 @@ pub(crate) fn impls_trait<'tcx>( trait_did: DefId, ) -> bool { tcx.infer_ctxt() - .build() + .build(TypingMode::non_body_analysis()) .type_implements_trait(trait_did, [ty], param_env) .must_apply_modulo_regions() } diff --git a/crates/bevy_api_gen/src/passes/find_trait_impls.rs b/crates/bevy_api_gen/src/passes/find_trait_impls.rs index 65f65e31..95418690 100644 --- a/crates/bevy_api_gen/src/passes/find_trait_impls.rs +++ b/crates/bevy_api_gen/src/passes/find_trait_impls.rs @@ -6,7 +6,7 @@ use rustc_infer::{ infer::{InferCtxt, TyCtxtInferExt}, traits::{Obligation, ObligationCause}, }; -use rustc_middle::ty::Ty; +use rustc_middle::ty::{Ty, TypingMode}; use rustc_span::DUMMY_SP; use rustc_trait_selection::traits::ObligationCtxt; @@ -105,7 +105,7 @@ fn type_impl_of_trait( //TODO: false negatives coming from this inference let ty = tcx.type_of(reflect_ty_did).instantiate_identity(); - let infcx = tcx.infer_ctxt().build(); + let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis()); let result = impl_matches(&infcx, ty, impl_did); log::trace!("Result: {:#?}", result); if result { diff --git a/makefile b/makefile index acd004c3..3362ee6c 100644 --- a/makefile +++ b/makefile @@ -21,7 +21,7 @@ PACKAGE=bevy_mod_scripting TEST_NAME= # # valgrind outputs a callgrind.out.. We can analyze this with kcachegrind # kcachegrind -NIGHTLY_VERSION=nightly-2024-05-20 +NIGHTLY_VERSION=nightly-2024-11-05 BEVY_VERSION=0.15.0-rc.2 GLAM_VERSION=0.29.0 CODEGEN_PATH=${PWD}/target/codegen @@ -61,10 +61,10 @@ clean_bevy: cd ${BEVY_PATH} && cargo clean generate_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' --features ${GEN_BEVY_FEATURES} + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen generate --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' --features ${GEN_BEVY_FEATURES} -vv collect_bevy: - cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' + cd ${BEVY_PATH} && cargo +${NIGHTLY_VERSION} bevy-api-gen collect --output ${OUTPUT_PATH} --template-args '{ "self_is_bevy_script_api": true}' -vv deletion_confirmation: @echo -n "This action will delete ALL files in directories: '${GENERATED_SRC_PATH}' amd ${OUTPUT_PATH} (y/N) " From 69d87673b1e30624a1dbcc2452c1e623f3103f61 Mon Sep 17 00:00:00 2001 From: makspll Date: Wed, 6 Nov 2024 22:38:58 +0000 Subject: [PATCH 05/15] Fix errors + regen --- crates/bevy_script_api/Cargo.toml | 1 + .../src/providers/bevy_a11y.rs | 69 + .../bevy_script_api/src/providers/bevy_ecs.rs | 130 +- .../src/providers/bevy_hierarchy.rs | 45 +- .../src/providers/bevy_input.rs | 948 +- .../src/providers/bevy_math.rs | 1464 ++- .../src/providers/bevy_reflect.rs | 8265 +++++++++++------ .../src/providers/bevy_time.rs | 64 +- .../src/providers/bevy_transform.rs | 177 +- .../src/providers/bevy_window.rs | 640 +- crates/bevy_script_api/src/providers/mod.rs | 4 + 11 files changed, 7688 insertions(+), 4119 deletions(-) create mode 100644 crates/bevy_script_api/src/providers/bevy_a11y.rs diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml index d4ed591f..1e49c377 100644 --- a/crates/bevy_script_api/Cargo.toml +++ b/crates/bevy_script_api/Cargo.toml @@ -28,6 +28,7 @@ bevy = { workspace = true, default-features = false, features = [ "bevy_sprite", "file_watcher", "multi_threaded", + "bevy_reflect", ] } uuid = "1.10" bevy_mod_scripting_core = { workspace = true } diff --git a/crates/bevy_script_api/src/providers/bevy_a11y.rs b/crates/bevy_script_api/src/providers/bevy_a11y.rs new file mode 100644 index 00000000..b6ef3788 --- /dev/null +++ b/crates/bevy_script_api/src/providers/bevy_a11y.rs @@ -0,0 +1,69 @@ +// @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::*; +extern crate self as bevy_script_api; +use bevy_script_api::{ + lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, +}; +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::a11y::Focus", functions[])] +struct Focus(ReflectedValue); +#[derive(Default)] +pub(crate) struct Globals; +impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { + fn add_instances< + 'lua, + T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>, + >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { + Ok(()) + } +} +pub struct BevyA11YAPIProvider; +impl bevy_mod_scripting_core::hosts::APIProvider for BevyA11YAPIProvider { + type APITarget = std::sync::Mutex; + type ScriptContext = std::sync::Mutex; + type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; + fn attach_api( + &mut self, + ctx: &mut Self::APITarget, + ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context"); + bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx) + .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other( + e.to_string(), + )) + } + fn get_doc_fragment(&self) -> Option { + Some( + bevy_mod_scripting_lua::docs::LuaDocFragment::new( + "BevyA11YAPI", + |tw| { + tw.document_global_instance::() + .expect("Something went wrong documenting globals") + .process_type::() + }, + ), + ) + } + fn setup_script( + &mut self, + script_data: &bevy_mod_scripting_core::hosts::ScriptData, + ctx: &mut Self::ScriptContext, + ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + Ok(()) + } + fn setup_script_runtime( + &mut self, + world_ptr: bevy_mod_scripting_core::world::WorldPointer, + _script_data: &bevy_mod_scripting_core::hosts::ScriptData, + ctx: &mut Self::ScriptContext, + ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + Ok(()) + } + fn register_with_app(&self, app: &mut bevy::app::App) { + app.register_foreign_lua_type::(); + } +} diff --git a/crates/bevy_script_api/src/providers/bevy_ecs.rs b/crates/bevy_script_api/src/providers/bevy_ecs.rs index 465b5fa8..003a8621 100644 --- a/crates/bevy_script_api/src/providers/bevy_ecs.rs +++ b/crates/bevy_script_api/src/providers/bevy_ecs.rs @@ -85,38 +85,73 @@ use bevy_script_api::{ r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] struct Entity {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnAdd", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnAdd", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnAdd {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnInsert", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnInsert", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnInsert {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy(derive(), remote = "bevy::ecs::world::OnRemove", functions[])] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnRemove", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] struct OnRemove {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "bevy::ecs::world::OnReplace", + functions[r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct OnReplace {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::ecs::component::ComponentId", functions[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(kind = "Function", output(proxy))] - fn new(index: usize) -> bevy::ecs::component::ComponentId; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Returns the index of the current component. - #[lua(kind = "Method")] - fn index(self) -> usize; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::component::ComponentId; "#, r#" @@ -131,15 +166,19 @@ struct OnRemove {} "#, 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(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::component::ComponentId; + #[lua(kind = "Function", output(proxy))] + fn new(index: usize) -> bevy::ecs::component::ComponentId; "#, r#" +/// Returns the index of the current component. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn index(self) -> usize; "#, r#" @@ -156,13 +195,8 @@ struct ComponentId(); remote = "bevy::ecs::component::Tick", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &component::Tick) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -208,8 +242,13 @@ struct ComponentId(); "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &component::Tick) -> bool; "#, r#" @@ -311,12 +350,6 @@ struct ComponentTicks {} )] fn eq(&self, #[proxy] other: &identifier::Identifier) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::ecs::identifier::Identifier; - "#, r#" /// Returns the value of the low segment of the [`Identifier`]. @@ -348,6 +381,12 @@ struct ComponentTicks {} #[lua(kind = "Function", output(proxy))] fn from_bits(value: u64) -> bevy::ecs::identifier::Identifier; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::identifier::Identifier; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -369,6 +408,27 @@ struct Identifier {} "#] )] struct EntityHash {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::ecs::removal_detection::RemovedComponentEntity", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::ecs::removal_detection::RemovedComponentEntity; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RemovedComponentEntity(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy(derive(), remote = "bevy::ecs::system::SystemIdMarker", functions[])] +struct SystemIdMarker {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -428,6 +488,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { .process_type::() .process_type::() .process_type::() + .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -446,6 +507,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { >, >() .process_type::() + .process_type::() + .process_type::() }, ), ) @@ -470,10 +533,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyEcsAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::ecs::removal_detection::RemovedComponentEntity, + >(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs index e064a5cc..e1bfc68d 100644 --- a/crates/bevy_script_api/src/providers/bevy_hierarchy.rs +++ b/crates/bevy_script_api/src/providers/bevy_hierarchy.rs @@ -33,11 +33,46 @@ struct Children(); derive(), remote = "bevy::hierarchy::prelude::Parent", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; + +"#, + r#" /// Gets the [`Entity`] ID of the parent. #[lua(kind = "Method", output(proxy))] fn get(&self) -> bevy::ecs::entity::Entity; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Parent(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::hierarchy::HierarchyEvent", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -47,13 +82,13 @@ struct Children(); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &components::parent::Parent) -> bool; + fn eq(&self, #[proxy] other: &events::HierarchyEvent) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::hierarchy::HierarchyEvent; "#, r#" @@ -63,7 +98,7 @@ fn index(&self) -> String { } "#] )] -struct Parent(); +struct HierarchyEvent {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -98,6 +133,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { .expect("Something went wrong documenting globals") .process_type::() .process_type::() + .process_type::() }, ), ) @@ -120,5 +156,6 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyHierarchyAPIProvider { fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs index d06224cc..72d379ab 100644 --- a/crates/bevy_script_api/src/providers/bevy_input.rs +++ b/crates/bevy_script_api/src/providers/bevy_input.rs @@ -11,94 +11,73 @@ use bevy_script_api::{ }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(clone), + derive(), remote = "bevy::input::gamepad::Gamepad", functions[r#" +/// Returns the USB vendor ID as assigned by the USB-IF, if available. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn vendor_id(&self) -> std::option::Option; "#, r#" +/// Returns the USB product ID as assigned by the [vendor], if available. +/// [vendor]: Self::vendor_id - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::Gamepad; + #[lua(kind = "Method")] + fn product_id(&self) -> std::option::Option; "#, r#" +/// Returns the left stick as a [`Vec2`] - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::Gamepad) -> bool; + #[lua(kind = "Method", output(proxy))] + fn left_stick(&self) -> bevy::math::Vec2; "#, r#" -/// Creates a new [`Gamepad`]. +/// Returns the right stick as a [`Vec2`] - #[lua(kind = "Function", output(proxy))] - fn new(id: usize) -> bevy::input::gamepad::Gamepad; + #[lua(kind = "Method", output(proxy))] + fn right_stick(&self) -> bevy::math::Vec2; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Gamepad { - id: usize, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadAxis", - functions[r#" +/// Returns the directional pad as a [`Vec2`] - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; + #[lua(kind = "Method", output(proxy))] + fn dpad(&self) -> bevy::math::Vec2; "#, r#" -/// Creates a new [`GamepadAxis`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadAxis, GamepadAxisType, Gamepad}; -/// # -/// let gamepad_axis = GamepadAxis::new( -/// Gamepad::new(1), -/// GamepadAxisType::LeftStickX, -/// ); -/// ``` +/// Returns `true` if the [`GamepadButton`] has been pressed. - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - ) -> bevy::input::gamepad::GamepadAxis; + #[lua(kind = "Method")] + fn pressed(&self, #[proxy] button_type: bevy::input::gamepad::GamepadButton) -> bool; "#, r#" +/// Returns `true` if the [`GamepadButton`] has been pressed during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + #[lua(kind = "Method")] + fn just_pressed( + &self, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + ) -> bool; "#, r#" +/// Returns `true` if the [`GamepadButton`] has been released during the current frame. +/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Method")] + fn just_released( + &self, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + ) -> bool; "#, r#" @@ -108,21 +87,22 @@ fn index(&self) -> String { } "#] )] -struct GamepadAxis { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, -} +struct Gamepad {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadAxisType", + remote = "bevy::input::gamepad::GamepadAxis", functions[r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadAxis; + "#, r#" @@ -132,13 +112,7 @@ struct GamepadAxis { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadAxisType) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadAxisType; + fn eq(&self, #[proxy] other: &gamepad::GamepadAxis) -> bool; "#, r#" @@ -148,7 +122,7 @@ fn index(&self) -> String { } "#] )] -struct GamepadAxisType {} +struct GamepadAxis {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -175,27 +149,6 @@ struct GamepadAxisType {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadButton; -"#, - r#" -/// Creates a new [`GamepadButton`]. -/// # Examples -/// ``` -/// # use bevy_input::gamepad::{GamepadButton, GamepadButtonType, Gamepad}; -/// # -/// let gamepad_button = GamepadButton::new( -/// Gamepad::new(1), -/// GamepadButtonType::South, -/// ); -/// ``` - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, - ) -> bevy::input::gamepad::GamepadButton; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -204,37 +157,15 @@ fn index(&self) -> String { } "#] )] -struct GamepadButton { - #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, - #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, -} +struct GamepadButton {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonType", + remote = "bevy::input::gamepad::GamepadSettings", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonType; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonType) -> bool; + fn clone(&self) -> bevy::input::gamepad::GamepadSettings; "#, r#" @@ -244,7 +175,17 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonType {} +struct GamepadSettings { + #[lua(output(proxy))] + default_button_settings: bevy::input::gamepad::ButtonSettings, + #[lua(output(proxy))] + default_axis_settings: bevy::input::gamepad::AxisSettings, + #[lua(output(proxy))] + default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, + button_settings: ReflectedValue, + axis_settings: ReflectedValue, + button_axis_settings: ReflectedValue, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -254,6 +195,12 @@ struct GamepadButtonType {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyCode; + "#, r#" @@ -265,12 +212,6 @@ struct GamepadButtonType {} )] fn eq(&self, #[proxy] other: &keyboard::KeyCode) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyCode; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -362,12 +303,6 @@ struct TouchInput { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::keyboard::KeyboardFocusLost; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -379,6 +314,12 @@ struct TouchInput { )] fn eq(&self, #[proxy] other: &keyboard::KeyboardFocusLost) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -394,6 +335,12 @@ struct KeyboardFocusLost {} remote = "bevy::input::keyboard::KeyboardInput", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::KeyboardInput; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -408,12 +355,6 @@ struct KeyboardFocusLost {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::KeyboardInput; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -429,27 +370,82 @@ struct KeyboardInput { logical_key: bevy::input::keyboard::Key, #[lua(output(proxy))] state: bevy::input::ButtonState, + repeat: bool, #[lua(output(proxy))] window: bevy::ecs::entity::Entity, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::mouse::MouseButtonInput", + remote = "bevy::input::mouse::AccumulatedMouseMotion", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::AccumulatedMouseMotion; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::AccumulatedMouseMotion) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AccumulatedMouseMotion { + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::mouse::AccumulatedMouseScroll", + functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + fn clone(&self) -> bevy::input::mouse::AccumulatedMouseScroll; "#, r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &mouse::AccumulatedMouseScroll) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AccumulatedMouseScroll { + #[lua(output(proxy))] + unit: bevy::input::mouse::MouseScrollUnit, + #[lua(output(proxy))] + delta: bevy::math::Vec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::mouse::MouseButtonInput", + functions[r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -458,6 +454,18 @@ struct KeyboardInput { )] fn eq(&self, #[proxy] other: &mouse::MouseButtonInput) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::mouse::MouseButtonInput; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -551,6 +559,19 @@ struct MouseWheel { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadAxisChangedEvent; +"#, + r#" +/// Creates a new [`GamepadAxisChangedEvent`] + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + entity: bevy::ecs::entity::Entity, + #[proxy] + axis: bevy::input::gamepad::GamepadAxis, + value: f32, + ) -> bevy::input::gamepad::GamepadAxisChangedEvent; + "#, r#" @@ -562,19 +583,6 @@ struct MouseWheel { )] fn eq(&self, #[proxy] other: &gamepad::GamepadAxisChangedEvent) -> bool; -"#, - r#" -/// Creates a [`GamepadAxisChangedEvent`]. - - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - gamepad: bevy::input::gamepad::Gamepad, - #[proxy] - axis_type: bevy::input::gamepad::GamepadAxisType, - value: f32, - ) -> bevy::input::gamepad::GamepadAxisChangedEvent; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -585,9 +593,9 @@ fn index(&self) -> String { )] struct GamepadAxisChangedEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, #[lua(output(proxy))] - axis_type: bevy::input::gamepad::GamepadAxisType, + axis: bevy::input::gamepad::GamepadAxis, value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] @@ -596,12 +604,6 @@ struct GamepadAxisChangedEvent { remote = "bevy::input::gamepad::GamepadButtonChangedEvent", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -612,14 +614,22 @@ struct GamepadAxisChangedEvent { "#, r#" -/// Creates a [`GamepadButtonChangedEvent`]. + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadButtonChangedEvent; + +"#, + r#" +/// Creates a new [`GamepadButtonChangedEvent`] #[lua(kind = "Function", output(proxy))] fn new( #[proxy] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, + #[proxy] + button: bevy::input::gamepad::GamepadButton, #[proxy] - button_type: bevy::input::gamepad::GamepadButtonType, + state: bevy::input::ButtonState, value: f32, ) -> bevy::input::gamepad::GamepadButtonChangedEvent; @@ -633,19 +643,32 @@ fn index(&self) -> String { )] struct GamepadButtonChangedEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + entity: bevy::ecs::entity::Entity, #[lua(output(proxy))] - button_type: bevy::input::gamepad::GamepadButtonType, + button: bevy::input::gamepad::GamepadButton, + #[lua(output(proxy))] + state: bevy::input::ButtonState, value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadButtonInput", + remote = "bevy::input::gamepad::GamepadButtonStateChangedEvent", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadButtonStateChangedEvent) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadButtonInput; + fn clone(&self) -> bevy::input::gamepad::GamepadButtonStateChangedEvent; "#, r#" @@ -655,14 +678,17 @@ struct GamepadButtonChangedEvent { "#, r#" +/// Creates a new [`GamepadButtonStateChangedEvent`] - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadButtonInput) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + entity: bevy::ecs::entity::Entity, + #[proxy] + button: bevy::input::gamepad::GamepadButton, + #[proxy] + state: bevy::input::ButtonState, + ) -> bevy::input::gamepad::GamepadButtonStateChangedEvent; "#, r#" @@ -672,7 +698,9 @@ fn index(&self) -> String { } "#] )] -struct GamepadButtonInput { +struct GamepadButtonStateChangedEvent { + #[lua(output(proxy))] + entity: bevy::ecs::entity::Entity, #[lua(output(proxy))] button: bevy::input::gamepad::GamepadButton, #[lua(output(proxy))] @@ -681,31 +709,43 @@ struct GamepadButtonInput { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnectionEvent", + remote = "bevy::input::gamepad::GamepadConnection", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; "#, r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadConnection; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadConnection {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadConnectionEvent", + functions[r#" /// Creates a [`GamepadConnectionEvent`]. #[lua(kind = "Function", output(proxy))] fn new( #[proxy] - gamepad: bevy::input::gamepad::Gamepad, + gamepad: bevy::ecs::entity::Entity, #[proxy] connection: bevy::input::gamepad::GamepadConnection, ) -> bevy::input::gamepad::GamepadConnectionEvent; @@ -724,6 +764,23 @@ struct GamepadButtonInput { #[lua(kind = "Method")] fn disconnected(&self) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadConnectionEvent; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadConnectionEvent) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -734,7 +791,7 @@ fn index(&self) -> String { )] struct GamepadConnectionEvent { #[lua(output(proxy))] - gamepad: bevy::input::gamepad::Gamepad, + gamepad: bevy::ecs::entity::Entity, #[lua(output(proxy))] connection: bevy::input::gamepad::GamepadConnection, } @@ -744,11 +801,34 @@ struct GamepadConnectionEvent { remote = "bevy::input::gamepad::GamepadEvent", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::gamepad::GamepadEvent; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadInfo", + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -756,7 +836,19 @@ struct GamepadConnectionEvent { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadEvent) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInfo; "#, r#" @@ -766,37 +858,134 @@ fn index(&self) -> String { } "#] )] -struct GamepadEvent {} +struct GamepadInfo { + name: std::string::String, + vendor_id: std::option::Option, + product_id: std::option::Option, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(), - remote = "bevy::input::gamepad::GamepadSettings", + derive(clone), + remote = "bevy::input::gamepad::GamepadInput", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadInput; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::GamepadInput) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct GamepadInput {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::GamepadRumbleRequest", + functions[r#" +/// Get the [`Entity`] associated with this request. + + #[lua(kind = "Method", output(proxy))] + fn gamepad(&self) -> bevy::ecs::entity::Entity; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadRumbleRequest; + +"#] +)] +struct GamepadRumbleRequest {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gamepad::RawGamepadAxisChangedEvent", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::RawGamepadAxisChangedEvent; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::RawGamepadAxisChangedEvent) -> bool; + +"#, + r#" +/// Creates a [`RawGamepadAxisChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::ecs::entity::Entity, + #[proxy] + axis_type: bevy::input::gamepad::GamepadAxis, + value: f32, + ) -> bevy::input::gamepad::RawGamepadAxisChangedEvent; + +"#, + r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { format!("{:?}", _self) } "#] )] -struct GamepadSettings { +struct RawGamepadAxisChangedEvent { #[lua(output(proxy))] - default_button_settings: bevy::input::gamepad::ButtonSettings, - #[lua(output(proxy))] - default_axis_settings: bevy::input::gamepad::AxisSettings, + gamepad: bevy::ecs::entity::Entity, #[lua(output(proxy))] - default_button_axis_settings: bevy::input::gamepad::ButtonAxisSettings, - button_settings: ReflectedValue, - axis_settings: ReflectedValue, - button_axis_settings: ReflectedValue, + axis: bevy::input::gamepad::GamepadAxis, + value: f32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gestures::PinchGesture", + remote = "bevy::input::gamepad::RawGamepadButtonChangedEvent", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::PinchGesture; + fn clone(&self) -> bevy::input::gamepad::RawGamepadButtonChangedEvent; + +"#, + r#" +/// Creates a [`RawGamepadButtonChangedEvent`]. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + gamepad: bevy::ecs::entity::Entity, + #[proxy] + button_type: bevy::input::gamepad::GamepadButton, + value: f32, + ) -> bevy::input::gamepad::RawGamepadButtonChangedEvent; "#, r#" @@ -807,7 +996,7 @@ struct GamepadSettings { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gestures::PinchGesture) -> bool; + fn eq(&self, #[proxy] other: &gamepad::RawGamepadButtonChangedEvent) -> bool; "#, r#" @@ -817,26 +1006,61 @@ fn index(&self) -> String { } "#] )] -struct PinchGesture(f32); +struct RawGamepadButtonChangedEvent { + #[lua(output(proxy))] + gamepad: bevy::ecs::entity::Entity, + #[lua(output(proxy))] + button: bevy::input::gamepad::GamepadButton, + value: f32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gestures::RotationGesture", + remote = "bevy::input::gamepad::RawGamepadEvent", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::RawGamepadEvent; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gestures::RotationGesture) -> bool; + fn eq(&self, #[proxy] other: &gamepad::RawGamepadEvent) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RawGamepadEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::input::gestures::PinchGesture", + functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::RotationGesture; + fn clone(&self) -> bevy::input::gestures::PinchGesture; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gestures::PinchGesture) -> bool; "#, r#" @@ -846,26 +1070,26 @@ fn index(&self) -> String { } "#] )] -struct RotationGesture(f32); +struct PinchGesture(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gestures::DoubleTapGesture", + remote = "bevy::input::gestures::RotationGesture", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gestures::RotationGesture; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gestures::DoubleTapGesture) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::DoubleTapGesture; + fn eq(&self, #[proxy] other: &gestures::RotationGesture) -> bool; "#, r#" @@ -875,15 +1099,15 @@ fn index(&self) -> String { } "#] )] -struct DoubleTapGesture {} +struct RotationGesture(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gestures::PanGesture", + remote = "bevy::input::gestures::DoubleTapGesture", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gestures::PanGesture; + fn clone(&self) -> bevy::input::gestures::DoubleTapGesture; "#, r#" @@ -894,7 +1118,7 @@ struct DoubleTapGesture {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gestures::PanGesture) -> bool; + fn eq(&self, #[proxy] other: &gestures::DoubleTapGesture) -> bool; "#, r#" @@ -904,39 +1128,26 @@ fn index(&self) -> String { } "#] )] -struct PanGesture(#[lua(output(proxy))] bevy::math::Vec2); +struct DoubleTapGesture {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::ButtonState", + remote = "bevy::input::gestures::PanGesture", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::ButtonState; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &ButtonState) -> bool; + fn eq(&self, #[proxy] other: &gestures::PanGesture) -> bool; "#, r#" -/// Is this button pressed? - #[lua(kind = "Method")] - fn is_pressed(&self) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gestures::PanGesture; "#, r#" @@ -946,16 +1157,29 @@ fn index(&self) -> String { } "#] )] -struct ButtonState {} +struct PanGesture(#[lua(output(proxy))] bevy::math::Vec2); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadInfo", + remote = "bevy::input::ButtonState", functions[r#" #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::ButtonState; + +"#, + r#" +/// Is this button pressed? + + #[lua(kind = "Method")] + fn is_pressed(&self) -> bool; + "#, r#" @@ -965,13 +1189,7 @@ struct ButtonState {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + fn eq(&self, #[proxy] other: &ButtonState) -> bool; "#, r#" @@ -981,14 +1199,18 @@ fn index(&self) -> String { } "#] )] -struct GamepadInfo { - name: std::string::String, -} +struct ButtonState {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::input::gamepad::ButtonSettings", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonSettings; + +"#, + r#" /// Returns `true` if the button is pressed. /// A button is considered pressed if the `value` passed is greater than or equal to the press threshold. @@ -1038,8 +1260,13 @@ struct GamepadInfo { "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonSettings; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &gamepad::ButtonSettings) -> bool; "#, r#" @@ -1064,12 +1291,6 @@ struct ButtonSettings {} )] fn eq(&self, #[proxy] other: &gamepad::AxisSettings) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::AxisSettings; - "#, r#" /// Get the value above which inputs will be rounded up to 1.0. @@ -1174,6 +1395,12 @@ struct ButtonSettings {} old_value: std::option::Option, ) -> std::option::Option; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::AxisSettings; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1188,6 +1415,12 @@ struct AxisSettings {} derive(clone), remote = "bevy::input::gamepad::ButtonAxisSettings", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; + +"#, + r#" /// Filters the `new_value` based on the `old_value`, according to the [`ButtonAxisSettings`]. /// Returns the clamped `new_value`, according to the [`ButtonAxisSettings`], if the change /// exceeds the settings threshold, and `None` otherwise. @@ -1199,12 +1432,6 @@ struct AxisSettings {} old_value: std::option::Option, ) -> std::option::Option; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::ButtonAxisSettings; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1221,11 +1448,21 @@ struct ButtonAxisSettings { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::input::gamepad::GamepadConnection", + remote = "bevy::input::gamepad::GamepadRumbleIntensity", 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(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadConnection; + #[lua(kind = "Function", output(proxy))] + fn weak_motor(intensity: f32) -> bevy::input::gamepad::GamepadRumbleIntensity; + +"#, + r#" +/// Creates a new rumble intensity with strong motor intensity set to the given value. +/// Clamped within the `0.0` to `1.0` range. + + #[lua(kind = "Function", output(proxy))] + fn strong_motor(intensity: f32) -> bevy::input::gamepad::GamepadRumbleIntensity; "#, r#" @@ -1236,7 +1473,13 @@ struct ButtonAxisSettings { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &gamepad::GamepadConnection) -> bool; + fn eq(&self, #[proxy] other: &gamepad::GamepadRumbleIntensity) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::gamepad::GamepadRumbleIntensity; "#, r#" @@ -1246,13 +1489,22 @@ fn index(&self) -> String { } "#] )] -struct GamepadConnection {} +struct GamepadRumbleIntensity { + strong_motor: f32, + weak_motor: f32, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::input::keyboard::Key", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::Key; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1267,12 +1519,6 @@ struct GamepadConnection {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::Key; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1288,6 +1534,12 @@ struct Key {} remote = "bevy::input::keyboard::NativeKeyCode", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::input::keyboard::NativeKeyCode; @@ -1302,12 +1554,6 @@ struct Key {} )] fn eq(&self, #[proxy] other: &keyboard::NativeKeyCode) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1323,8 +1569,8 @@ struct NativeKeyCode {} remote = "bevy::input::keyboard::NativeKey", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::keyboard::NativeKey; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1340,8 +1586,8 @@ struct NativeKeyCode {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::keyboard::NativeKey; "#, r#" @@ -1396,6 +1642,12 @@ struct MouseScrollUnit {} #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::TouchPhase; + "#, r#" @@ -1407,12 +1659,6 @@ struct MouseScrollUnit {} )] fn eq(&self, #[proxy] other: &touch::TouchPhase) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::TouchPhase; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1428,6 +1674,12 @@ struct TouchPhase {} remote = "bevy::input::touch::ForceTouch", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::input::touch::ForceTouch; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1436,12 +1688,6 @@ struct TouchPhase {} )] fn eq(&self, #[proxy] other: &touch::ForceTouch) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::touch::ForceTouch; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1460,40 +1706,51 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { instances .add_instance( - "Gamepad", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "GamepadAxisChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadAxisChangedEvent, + >::new, + )?; + instances + .add_instance( + "GamepadButtonChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadButtonChangedEvent, + >::new, )?; instances .add_instance( - "GamepadAxis", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "GamepadButtonStateChangedEvent", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< + LuaGamepadButtonStateChangedEvent, + >::new, )?; instances .add_instance( - "GamepadButton", + "GamepadConnectionEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButton, + LuaGamepadConnectionEvent, >::new, )?; instances .add_instance( - "GamepadAxisChangedEvent", + "RawGamepadAxisChangedEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadAxisChangedEvent, + LuaRawGamepadAxisChangedEvent, >::new, )?; instances .add_instance( - "GamepadButtonChangedEvent", + "RawGamepadButtonChangedEvent", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadButtonChangedEvent, + LuaRawGamepadButtonChangedEvent, >::new, )?; instances .add_instance( - "GamepadConnectionEvent", + "GamepadRumbleIntensity", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::< - LuaGamepadConnectionEvent, + LuaGamepadRumbleIntensity, >::new, )?; Ok(()) @@ -1522,28 +1779,16 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { tw.document_global_instance::() .expect("Something went wrong documenting globals") .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadAxis, - >, - >() - .process_type::() .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaGamepadButton, - >, - >() - .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() + .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() @@ -1559,7 +1804,13 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { LuaGamepadButtonChangedEvent, >, >() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadButtonStateChangedEvent, + >, + >() + .process_type::() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -1567,17 +1818,36 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { >, >() .process_type::() - .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRawGamepadAxisChangedEvent, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaRawGamepadButtonChangedEvent, + >, + >() + .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() .process_type::() - .process_type::() .process_type::() .process_type::() .process_type::() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaGamepadRumbleIntensity, + >, + >() .process_type::() .process_type::() .process_type::() @@ -1606,14 +1876,15 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -1621,20 +1892,31 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { app.register_foreign_lua_type::< bevy::input::gamepad::GamepadButtonChangedEvent, >(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::input::gamepad::GamepadButtonStateChangedEvent, + >(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::< + bevy::input::gamepad::RawGamepadAxisChangedEvent, + >(); + app.register_foreign_lua_type::< + bevy::input::gamepad::RawGamepadButtonChangedEvent, + >(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_math.rs b/crates/bevy_script_api/src/providers/bevy_math.rs index 461fb0b5..e6c8fd2f 100644 --- a/crates/bevy_script_api/src/providers/bevy_math.rs +++ b/crates/bevy_script_api/src/providers/bevy_math.rs @@ -8,6 +8,70 @@ use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::AspectRatio", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::AspectRatio; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &aspect_ratio::AspectRatio) -> bool; + +"#, + r#" +/// Returns the aspect ratio as a f32 value. + + #[lua(kind = "Method")] + fn ratio(&self) -> f32; + +"#, + r#" +/// Returns the inverse of this aspect ratio (height/width). + + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::AspectRatio; + +"#, + r#" +/// Returns true if the aspect ratio represents a landscape orientation. + + #[lua(kind = "Method")] + fn is_landscape(&self) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio represents a portrait orientation. + + #[lua(kind = "Method")] + fn is_portrait(&self) -> bool; + +"#, + r#" +/// Returns true if the aspect ratio is exactly square. + + #[lua(kind = "Method")] + fn is_square(&self) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AspectRatio(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::math::CompassOctant", @@ -80,25 +144,116 @@ struct CompassQuadrant {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::AspectRatio", + remote = "bevy::math::Isometry2d", functions[r#" -/// Create a new `AspectRatio` from a given `width` and `height`. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Isometry2d) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a rotation and a translation. + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + translation: bevy::math::prelude::Vec2, + #[proxy] + rotation: bevy::math::Rot2, + ) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a rotation. + + #[lua(kind = "Function", output(proxy))] + fn from_rotation(#[proxy] rotation: bevy::math::Rot2) -> bevy::math::Isometry2d; + +"#, + r#" +/// Create a two-dimensional isometry from a translation. #[lua(kind = "Function", output(proxy))] - fn new(width: f32, height: f32) -> bevy::math::AspectRatio; + fn from_translation( + #[proxy] + translation: bevy::math::prelude::Vec2, + ) -> bevy::math::Isometry2d; "#, r#" -/// Create a new `AspectRatio` from a given amount of `x` pixels and `y` pixels. +/// Create a two-dimensional isometry from a translation with the given `x` and `y` components. #[lua(kind = "Function", output(proxy))] - fn from_pixels(x: u32, y: u32) -> bevy::math::AspectRatio; + fn from_xy(x: f32, y: f32) -> bevy::math::Isometry2d; + +"#, + r#" +/// The inverse isometry that undoes this one. + + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::Isometry2d; + +"#, + r#" +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua(kind = "Method", output(proxy))] + fn inverse_mul( + &self, + #[proxy] + rhs: bevy::math::Isometry2d, + ) -> bevy::math::Isometry2d; + +"#, + r#" +/// Transform a point by rotating and translating it using this isometry. + + #[lua(kind = "Method", output(proxy))] + fn transform_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Transform a point by rotating and translating it using the inverse of this isometry. +/// This is more efficient than `iso.inverse().transform_point(point)` for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. + + #[lua(kind = "Method", output(proxy))] + fn inverse_transform_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::AspectRatio; + fn clone(&self) -> bevy::math::Isometry2d; "#, r#" @@ -109,7 +264,19 @@ struct CompassQuadrant {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &aspect_ratio::AspectRatio) -> bool; + fn eq(&self, #[proxy] other: &isometry::Isometry2d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Dir2) -> bevy::math::prelude::Dir2; "#, r#" @@ -119,46 +286,136 @@ fn index(&self) -> String { } "#] )] -struct AspectRatio(); +struct Isometry2d { + #[lua(output(proxy))] + rotation: bevy::math::Rot2, + #[lua(output(proxy))] + translation: bevy::math::prelude::Vec2, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::Ray2d", + remote = "bevy::math::Isometry3d", functions[r#" -/// Create a new `Ray2d` from a given origin and direction -/// # Panics -/// Panics if the given `direction` is zero (or very close to zero), or non-finite. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Dir3) -> bevy::math::prelude::Dir3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec3) -> bevy::math::prelude::Vec3; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Isometry3d; + +"#, + r#" +/// Create a three-dimensional isometry from a rotation. #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - origin: bevy::math::prelude::Vec2, + fn from_rotation( #[proxy] - direction: bevy::math::prelude::Vec2, - ) -> bevy::math::Ray2d; + rotation: bevy::math::prelude::Quat, + ) -> bevy::math::Isometry3d; "#, r#" -/// Get a point at a given distance along the ray +/// Create a three-dimensional isometry from a translation with the given `x`, `y`, and `z` components. + + #[lua(kind = "Function", output(proxy))] + fn from_xyz(x: f32, y: f32, z: f32) -> bevy::math::Isometry3d; + +"#, + r#" +/// The inverse isometry that undoes this one. #[lua(kind = "Method", output(proxy))] - fn get_point(&self, distance: f32) -> bevy::math::prelude::Vec2; + fn inverse(&self) -> bevy::math::Isometry3d; "#, r#" -/// Get the distance to a plane if the ray intersects it +/// Compute `iso1.inverse() * iso2` in a more efficient way for one-shot cases. +/// If the same isometry is used multiple times, it is more efficient to instead compute +/// the inverse once and use that for each transformation. - #[lua(kind = "Method")] - fn intersect_plane( + #[lua(kind = "Method", output(proxy))] + fn inverse_mul( &self, #[proxy] - plane_origin: bevy::math::prelude::Vec2, - #[proxy] - plane: bevy::math::primitives::Plane2d, - ) -> std::option::Option; + rhs: bevy::math::Isometry3d, + ) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &isometry::Isometry3d) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Isometry3d) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Isometry3d { + #[lua(output(proxy))] + rotation: bevy::math::prelude::Quat, + #[lua(output(proxy))] + translation: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Ray2d", + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -174,6 +431,38 @@ struct AspectRatio(); #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::Ray2d; +"#, + r#" +/// Create a new `Ray2d` from a given origin and direction + + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + origin: bevy::math::prelude::Vec2, + #[proxy] + direction: bevy::math::prelude::Dir2, + ) -> bevy::math::Ray2d; + +"#, + r#" +/// Get a point at a given distance along the ray + + #[lua(kind = "Method", output(proxy))] + fn get_point(&self, distance: f32) -> bevy::math::prelude::Vec2; + +"#, + r#" +/// Get the distance to a plane if the ray intersects it + + #[lua(kind = "Method")] + fn intersect_plane( + &self, + #[proxy] + plane_origin: bevy::math::prelude::Vec2, + #[proxy] + plane: bevy::math::primitives::Plane2d, + ) -> std::option::Option; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -197,29 +486,16 @@ struct Ray2d { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::Ray3d; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &ray::Ray3d) -> bool; - "#, r#" /// Create a new `Ray3d` from a given origin and direction -/// # Panics -/// Panics if the given `direction` is zero (or very close to zero), or non-finite. #[lua(kind = "Function", output(proxy))] fn new( #[proxy] origin: bevy::math::prelude::Vec3, #[proxy] - direction: bevy::math::prelude::Vec3, + direction: bevy::math::prelude::Dir3, ) -> bevy::math::Ray3d; "#, @@ -242,6 +518,17 @@ struct Ray2d { plane: bevy::math::primitives::InfinitePlane3d, ) -> std::option::Option; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &ray::Ray3d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -261,20 +548,17 @@ struct Ray3d { derive(clone), remote = "bevy::math::Rot2", functions[r#" -/// Rotates a [`Vec2`] by a [`Rot2`]. #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; + fn eq(&self, #[proxy] other: &rotation2d::Rot2) -> bool; "#, r#" -/// Rotates the [`Dir2`] using a [`Rot2`]. #[lua( as_trait = "std::ops::Mul", @@ -283,21 +567,24 @@ struct Ray3d { composite = "mul", metamethod = "Mul", )] - fn mul( - self, - #[proxy] - direction: bevy::math::prelude::Dir2, - ) -> bevy::math::prelude::Dir2; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::Rot2; + fn mul(self, #[proxy] rhs: bevy::math::Rot2) -> bevy::math::Rot2; "#, r#" /// Creates a [`Rot2`] from a counterclockwise angle in radians. +/// # Note +/// The input rotation will always be clamped to the range `(-Ï€, Ï€]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// # use std::f32::consts::{FRAC_PI_2, PI}; +/// let rot1 = Rot2::radians(3.0 * FRAC_PI_2); +/// let rot2 = Rot2::radians(-FRAC_PI_2); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::radians(PI); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` #[lua(kind = "Function", output(proxy))] fn radians(radians: f32) -> bevy::math::Rot2; @@ -305,10 +592,41 @@ struct Ray3d { "#, r#" /// Creates a [`Rot2`] from a counterclockwise angle in degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-180°, 180°]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::degrees(270.0); +/// let rot2 = Rot2::degrees(-90.0); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::degrees(180.0); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` #[lua(kind = "Function", output(proxy))] fn degrees(degrees: f32) -> bevy::math::Rot2; +"#, + r#" +/// Creates a [`Rot2`] from a counterclockwise fraction of a full turn of 360 degrees. +/// # Note +/// The input rotation will always be clamped to the range `(-50%, 50%]` by design. +/// # Example +/// ``` +/// # use bevy_math::Rot2; +/// # use approx::assert_relative_eq; +/// let rot1 = Rot2::turn_fraction(0.75); +/// let rot2 = Rot2::turn_fraction(-0.25); +/// assert_relative_eq!(rot1, rot2); +/// let rot3 = Rot2::turn_fraction(0.5); +/// assert_relative_eq!(rot1 * rot1, rot3); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn turn_fraction(fraction: f32) -> bevy::math::Rot2; + "#, r#" /// Creates a [`Rot2`] from the sine and cosine of an angle in radians. @@ -333,6 +651,13 @@ struct Ray3d { #[lua(kind = "Method")] fn as_degrees(self) -> f32; +"#, + r#" +/// Returns the rotation as a fraction of a full 360 degree turn. + + #[lua(kind = "Method")] + fn as_turn_fraction(self) -> f32; + "#, r#" /// Returns the sine and cosine of the rotation angle in radians. @@ -383,6 +708,15 @@ struct Ray3d { #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Rot2; +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`](crate::Dir3::fast_renormalize) for an example of when such error accumulation might occur. + + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::Rot2; + "#, r#" /// Returns `true` if the rotation is neither infinite nor NaN. @@ -487,6 +821,13 @@ struct Ray3d { "#, r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::Rot2; + +"#, + r#" +/// Rotates a [`Vec2`] by a [`Rot2`]. + #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -494,18 +835,24 @@ struct Ray3d { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Rot2) -> bevy::math::Rot2; + fn mul(self, #[proxy] rhs: bevy::math::prelude::Vec2) -> bevy::math::prelude::Vec2; "#, r#" +/// Rotates the [`Dir2`] using a [`Rot2`]. #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &rotation2d::Rot2) -> bool; + fn mul( + self, + #[proxy] + direction: bevy::math::prelude::Dir2, + ) -> bevy::math::prelude::Dir2; "#, r#" @@ -524,6 +871,35 @@ struct Rot2 { derive(clone), remote = "bevy::math::prelude::Dir2", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &direction::Dir2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir2; + +"#, + r#" /// Create a [`Dir2`] from a [`Vec2`] that is already normalized. /// # Warning /// `value` must be normalized, i.e its length must be `1.0`. @@ -534,6 +910,15 @@ struct Rot2 { value: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Dir2; +"#, + r#" +/// Create a direction from its `x` and `y` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x` and `y` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn from_xy_unchecked(x: f32, y: f32) -> bevy::math::prelude::Dir2; + "#, r#" /// Returns the inner [`Vec2`] @@ -617,9 +1002,12 @@ struct Rot2 { "#, r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Dir2; + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir2; "#, r#" @@ -633,29 +1021,6 @@ struct Rot2 { )] fn mul(self, rhs: f32) -> bevy::math::prelude::Vec2; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &direction::Dir2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::prelude::Dir2; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -680,6 +1045,12 @@ struct Dir2(); )] fn neg(self) -> bevy::math::prelude::Dir3; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir3; + "#, r#" /// Create a [`Dir3`] from a [`Vec3`] that is already normalized. @@ -692,6 +1063,15 @@ struct Dir2(); value: bevy::math::prelude::Vec3, ) -> bevy::math::prelude::Dir3; +"#, + r#" +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> bevy::math::prelude::Dir3; + "#, r#" /// Returns the inner [`Vec3`] @@ -733,32 +1113,57 @@ struct Dir2(); "#, r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// # Example +/// The following seemingly benign code would start accumulating errors over time, +/// leading to `dir` eventually not being normalized anymore. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// } +/// ``` +/// Instead, do the following. +/// ``` +/// # use bevy_math::prelude::*; +/// # let N: usize = 200; +/// let mut dir = Dir3::X; +/// let quaternion = Quat::from_euler(EulerRot::XYZ, 1.0, 2.0, 3.0); +/// for i in 0..N { +/// dir = quaternion * dir; +/// dir = dir.fast_renormalize(); +/// } +/// ``` - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Dir3; + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &direction::Dir3) -> bool; + fn mul(self, rhs: f32) -> bevy::math::prelude::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, rhs: f32) -> bevy::math::prelude::Vec3; + fn eq(&self, #[proxy] other: &direction::Dir3) -> bool; "#, r#" @@ -787,19 +1192,20 @@ struct Dir3(); "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Dir3A; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::prelude::Dir3A; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &direction::Dir3A) -> bool; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Dir3A; "#, r#" @@ -810,6 +1216,15 @@ struct Dir3(); #[lua(kind = "Function", output(proxy))] fn new_unchecked(#[proxy] value: bevy::math::Vec3A) -> bevy::math::prelude::Dir3A; +"#, + r#" +/// Create a direction from its `x`, `y`, and `z` components, assuming the resulting vector is normalized. +/// # Warning +/// The vector produced from `x`, `y`, and `z` must be normalized, i.e its length must be `1.0`. + + #[lua(kind = "Function", output(proxy))] + fn from_xyz_unchecked(x: f32, y: f32, z: f32) -> bevy::math::prelude::Dir3A; + "#, r#" /// Returns the inner [`Vec3A`] @@ -849,17 +1264,25 @@ struct Dir3(); s: f32, ) -> bevy::math::prelude::Dir3A; +"#, + r#" +/// Returns `self` after an approximate normalization, assuming the value is already nearly normalized. +/// Useful for preventing numerical error accumulation. +/// See [`Dir3::fast_renormalize`] for an example of when such error accumulation might occur. + + #[lua(kind = "Method", output(proxy))] + fn fast_renormalize(self) -> bevy::math::prelude::Dir3A; + "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "eq", + metamethod = "Eq", )] - fn neg(self) -> bevy::math::prelude::Dir3A; + fn eq(&self, #[proxy] other: &direction::Dir3A) -> bool; "#, r#" @@ -875,6 +1298,12 @@ struct Dir3A(); derive(clone), remote = "bevy::math::prelude::IRect", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::IRect; + +"#, + r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. /// They only need to be two opposite corners. @@ -913,7 +1342,7 @@ struct Dir3A(); "#, r#" /// Create a new rectangle from its center and size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the size contains odd numbers they will be rounded down to the nearest whole number. /// # Panics /// This method panics if any of the components of the size is negative. @@ -1009,7 +1438,7 @@ struct Dir3A(); "#, r#" /// Rectangle half-size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. /// # Examples /// ``` @@ -1024,7 +1453,7 @@ struct Dir3A(); "#, r#" /// The center point of the rectangle. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. /// # Examples /// ``` @@ -1158,12 +1587,6 @@ struct Dir3A(); #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::IRect; - "#, r#" @@ -1194,6 +1617,23 @@ struct IRect { derive(clone), remote = "bevy::math::prelude::Rect", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &rects::rect::Rect) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::prelude::Rect; + +"#, + r#" /// Create a new rectangle from two corner points. /// The two points do not need to be the minimum and/or maximum corners. /// They only need to be two opposite corners. @@ -1488,23 +1928,6 @@ struct IRect { #[lua(kind = "Method", output(proxy))] fn as_urect(&self) -> bevy::math::prelude::URect; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::prelude::Rect; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &rects::rect::Rect) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1562,7 +1985,7 @@ struct Rect { "#, r#" /// Create a new rectangle from its center and size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the size contains odd numbers they will be rounded down to the nearest whole number. /// # Panics /// This method panics if any of the components of the size is negative or if `origin - (size / 2)` results in any negatives. @@ -1658,7 +2081,7 @@ struct Rect { "#, r#" /// Rectangle half-size. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size. /// # Examples /// ``` @@ -1673,7 +2096,7 @@ struct Rect { "#, r#" /// The center point of the rectangle. -/// # Rounding Behaviour +/// # Rounding Behavior /// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center. /// # Examples /// ``` @@ -1851,6 +2274,12 @@ struct Affine3 { derive(clone), remote = "bevy::math::bounding::Aabb2d", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::Aabb2d; + +"#, + r#" /// Constructs an AABB from its center and half-size. #[lua(kind = "Function", output(proxy))] @@ -1881,12 +2310,6 @@ struct Affine3 { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::Aabb2d; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2023,22 +2446,80 @@ struct Circle { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::Arc2d", + remote = "bevy::math::primitives::Annulus", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Arc2d; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &primitives::dim2::Arc2d) -> bool; + fn eq(&self, #[proxy] other: &primitives::dim2::Annulus) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Annulus; + +"#, + r#" +/// Create a new [`Annulus`] from the radii of the inner and outer circle + + #[lua(kind = "Function", output(proxy))] + fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Annulus; + +"#, + r#" +/// Get the diameter of the annulus + + #[lua(kind = "Method")] + fn diameter(&self) -> f32; + +"#, + r#" +/// Get the thickness of the annulus + + #[lua(kind = "Method")] + fn thickness(&self) -> f32; + +"#, + r#" +/// Finds the point on the annulus that is closest to the given `point`: +/// - If the point is outside of the annulus completely, the returned point will be on the outer perimeter. +/// - If the point is inside of the inner circle (hole) of the annulus, the returned point will be on the inner perimeter. +/// - Otherwise, the returned point is overlapping the annulus and returned as is. + + #[lua(kind = "Method", output(proxy))] + fn closest_point( + &self, + #[proxy] + point: bevy::math::prelude::Vec2, + ) -> bevy::math::prelude::Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Annulus { + #[lua(output(proxy))] + inner_circle: bevy::math::primitives::Circle, + #[lua(output(proxy))] + outer_circle: bevy::math::primitives::Circle, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::Arc2d", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Arc2d; "#, r#" @@ -2161,6 +2642,17 @@ struct Circle { #[lua(kind = "Method")] fn is_major(&self) -> bool; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Arc2d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2178,21 +2670,17 @@ struct Arc2d { derive(clone), remote = "bevy::math::primitives::Capsule2d", functions[r#" +/// Create a new `Capsule2d` from a radius and length - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Capsule2d) -> bool; + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; "#, r#" -/// Create a new `Capsule2d` from a radius and length +/// Get the part connecting the semicircular ends of the capsule as a [`Rectangle`] - #[lua(kind = "Function", output(proxy))] - fn new(radius: f32, length: f32) -> bevy::math::primitives::Capsule2d; + #[lua(kind = "Method", output(proxy))] + fn to_inner_rectangle(&self) -> bevy::math::primitives::Rectangle; "#, r#" @@ -2200,6 +2688,17 @@ struct Arc2d { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Capsule2d; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Capsule2d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2347,29 +2846,12 @@ fn index(&self) -> String { struct CircularSector { #[lua(output(proxy))] arc: bevy::math::primitives::Arc2d, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::primitives::CircularSegment", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::CircularSegment; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::CircularSegment) -> bool; - -"#, - r#" +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::primitives::CircularSegment", + functions[r#" /// Create a new [`CircularSegment`] from a `radius`, and an `angle` #[lua(kind = "Function", output(proxy))] @@ -2470,6 +2952,23 @@ struct CircularSector { #[lua(kind = "Method")] fn area(&self) -> f32; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::CircularSegment) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::CircularSegment; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2487,17 +2986,6 @@ struct CircularSegment { derive(clone), remote = "bevy::math::primitives::Ellipse", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Ellipse) -> bool; - -"#, - r#" /// Create a new `Ellipse` from half of its width and height. /// This corresponds to the two perpendicular radii defining the ellipse. @@ -2546,6 +3034,17 @@ struct CircularSegment { #[lua(kind = "Method")] fn semi_minor(&self) -> f32; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Ellipse) -> bool; + "#, r#" @@ -2601,15 +3100,9 @@ struct Line2d { derive(clone), remote = "bevy::math::primitives::Plane2d", functions[r#" -/// Create a new `Plane2d` from a normal -/// # Panics -/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - #[lua(kind = "Function", output(proxy))] - fn new( - #[proxy] - normal: bevy::math::prelude::Vec2, - ) -> bevy::math::primitives::Plane2d; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Plane2d; "#, r#" @@ -2624,9 +3117,15 @@ struct Line2d { "#, r#" +/// Create a new `Plane2d` from a normal +/// # Panics +/// Panics if the given `normal` is zero (or very close to zero), or non-finite. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Plane2d; + #[lua(kind = "Function", output(proxy))] + fn new( + #[proxy] + normal: bevy::math::prelude::Vec2, + ) -> bevy::math::primitives::Plane2d; "#, r#" @@ -2700,6 +3199,12 @@ struct Plane2d { point: bevy::math::prelude::Vec2, ) -> bevy::math::prelude::Vec2; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Rectangle; + "#, r#" @@ -2711,12 +3216,6 @@ struct Plane2d { )] fn eq(&self, #[proxy] other: &primitives::dim2::Rectangle) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Rectangle; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2734,30 +3233,13 @@ struct Rectangle { derive(clone), remote = "bevy::math::primitives::RegularPolygon", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::RegularPolygon; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::RegularPolygon) -> bool; - -"#, - r#" /// Create a new `RegularPolygon` /// from the radius of the circumcircle and a number of sides /// # Panics /// Panics if `circumradius` is negative #[lua(kind = "Function", output(proxy))] - fn new(circumradius: f32, sides: usize) -> bevy::math::primitives::RegularPolygon; + fn new(circumradius: f32, sides: u32) -> bevy::math::primitives::RegularPolygon; "#, r#" @@ -2819,6 +3301,23 @@ struct Rectangle { #[lua(kind = "Method")] fn external_angle_radians(&self) -> f32; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::RegularPolygon) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::RegularPolygon; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2830,7 +3329,7 @@ fn index(&self) -> String { struct RegularPolygon { #[lua(output(proxy))] circumcircle: bevy::math::primitives::Circle, - sides: usize, + sides: u32, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -2838,12 +3337,6 @@ struct RegularPolygon { remote = "bevy::math::primitives::Rhombus", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Rhombus; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -2852,6 +3345,12 @@ struct RegularPolygon { )] fn eq(&self, #[proxy] other: &primitives::dim2::Rhombus) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Rhombus; + "#, r#" /// Create a new `Rhombus` from a vertical and horizontal diagonal sizes. @@ -2929,6 +3428,17 @@ struct Rhombus { derive(clone), remote = "bevy::math::primitives::Segment2d", functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim2::Segment2d) -> bool; + +"#, + r#" /// Create a new `Segment2d` from a direction and full length of the segment #[lua(kind = "Function", output(proxy))] @@ -2958,17 +3468,6 @@ struct Rhombus { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Segment2d; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim2::Segment2d) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -2987,12 +3486,6 @@ struct Segment2d { derive(clone), remote = "bevy::math::primitives::Triangle2d", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Triangle2d; - -"#, - r#" /// Create a new `Triangle2d` from points `a`, `b`, and `c` #[lua(kind = "Function", output(proxy))] @@ -3054,6 +3547,12 @@ struct Segment2d { )] fn eq(&self, #[proxy] other: &primitives::dim2::Triangle2d) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Triangle2d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3100,6 +3599,12 @@ struct Aabb3d { derive(clone), remote = "bevy::math::bounding::BoundingSphere", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::BoundingSphere; + +"#, + r#" /// Get the radius of the bounding sphere #[lua(kind = "Method")] @@ -3112,12 +3617,6 @@ struct Aabb3d { #[lua(kind = "Method", output(proxy))] fn aabb_3d(&self) -> bevy::math::bounding::Aabb3d; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::BoundingSphere; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3137,6 +3636,12 @@ struct BoundingSphere { derive(clone), remote = "bevy::math::primitives::Sphere", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Sphere; + +"#, + r#" /// Create a new [`Sphere`] from a `radius` #[lua(kind = "Function", output(proxy))] @@ -3173,12 +3678,6 @@ struct BoundingSphere { )] fn eq(&self, #[proxy] other: &primitives::dim3::Sphere) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Sphere; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3254,6 +3753,12 @@ struct Sphere { point: bevy::math::prelude::Vec3, ) -> bevy::math::prelude::Vec3; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cuboid; + "#, r#" @@ -3265,12 +3770,6 @@ struct Sphere { )] fn eq(&self, #[proxy] other: &primitives::dim3::Cuboid) -> bool; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Cuboid; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3349,17 +3848,6 @@ struct Cylinder { derive(clone), remote = "bevy::math::primitives::Capsule3d", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Capsule3d) -> bool; - -"#, - r#" /// Create a new `Capsule3d` from a radius and length #[lua(kind = "Function", output(proxy))] @@ -3379,6 +3867,17 @@ struct Cylinder { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::math::primitives::Capsule3d; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Capsule3d) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3407,9 +3906,10 @@ struct Capsule3d { "#, r#" +/// Create a new [`Cone`] from a radius and height. - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Cone; + #[lua(kind = "Function", output(proxy))] + fn new(radius: f32, height: f32) -> bevy::math::primitives::Cone; "#, r#" @@ -3441,6 +3941,12 @@ struct Capsule3d { #[lua(kind = "Method")] fn base_area(&self) -> f32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Cone; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3459,12 +3965,6 @@ struct Cone { remote = "bevy::math::primitives::ConicalFrustum", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::ConicalFrustum; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -3473,6 +3973,12 @@ struct Cone { )] fn eq(&self, #[proxy] other: &primitives::dim3::ConicalFrustum) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::ConicalFrustum; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3492,12 +3998,6 @@ struct ConicalFrustum { remote = "bevy::math::primitives::InfinitePlane3d", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::InfinitePlane3d; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -3506,6 +4006,68 @@ struct ConicalFrustum { )] fn eq(&self, #[proxy] other: &primitives::dim3::InfinitePlane3d) -> bool; +"#, + r#" +/// Computes an [`Isometry3d`] which transforms points from the plane in 3D space with the given +/// `origin` to the XY-plane. +/// ## Guarantees +/// * the transformation is a [congruence] meaning it will preserve all distances and angles of +/// the transformed geometry +/// * uses the least rotation possible to transform the geometry +/// * if two geometries are transformed with the same isometry, then the relations between +/// them, like distances, are also preserved +/// * compared to projections, the transformation is lossless (up to floating point errors) +/// reversible +/// ## Non-Guarantees +/// * the rotation used is generally not unique +/// * the orientation of the transformed geometry in the XY plane might be arbitrary, to +/// enforce some kind of alignment the user has to use an extra transformation ontop of this +/// one +/// See [`isometries_xy`] for example usescases. +/// [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) +/// [`isometries_xy`]: `InfinitePlane3d::isometries_xy` + + #[lua(kind = "Method", output(proxy))] + fn isometry_into_xy( + &self, + #[proxy] + origin: bevy::math::prelude::Vec3, + ) -> bevy::math::Isometry3d; + +"#, + r#" +/// Computes an [`Isometry3d`] which transforms points from the XY-plane to this plane with the +/// given `origin`. +/// ## Guarantees +/// * the transformation is a [congruence] meaning it will preserve all distances and angles of +/// the transformed geometry +/// * uses the least rotation possible to transform the geometry +/// * if two geometries are transformed with the same isometry, then the relations between +/// them, like distances, are also preserved +/// * compared to projections, the transformation is lossless (up to floating point errors) +/// reversible +/// ## Non-Guarantees +/// * the rotation used is generally not unique +/// * the orientation of the transformed geometry in the XY plane might be arbitrary, to +/// enforce some kind of alignment the user has to use an extra transformation ontop of this +/// one +/// See [`isometries_xy`] for example usescases. +/// [congruence]: https://en.wikipedia.org/wiki/Congruence_(geometry) +/// [`isometries_xy`]: `InfinitePlane3d::isometries_xy` + + #[lua(kind = "Method", output(proxy))] + fn isometry_from_xy( + &self, + #[proxy] + origin: bevy::math::prelude::Vec3, + ) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::InfinitePlane3d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3524,12 +4086,6 @@ struct InfinitePlane3d { remote = "bevy::math::primitives::Line3d", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Line3d; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -3538,6 +4094,12 @@ struct InfinitePlane3d { )] fn eq(&self, #[proxy] other: &primitives::dim3::Line3d) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Line3d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -3555,6 +4117,12 @@ struct Line3d { derive(clone), remote = "bevy::math::primitives::Segment3d", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Segment3d; + +"#, + r#" /// Create a new `Segment3d` from a direction and full length of the segment #[lua(kind = "Function", output(proxy))] @@ -3578,12 +4146,6 @@ struct Line3d { #[lua(kind = "Method", output(proxy))] fn point2(&self) -> bevy::math::prelude::Vec3; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Segment3d; - "#, r#" @@ -3613,6 +4175,12 @@ struct Segment3d { derive(clone), remote = "bevy::math::primitives::Torus", functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Torus; + +"#, + 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 @@ -3638,12 +4206,6 @@ struct Segment3d { #[lua(kind = "Method")] fn outer_radius(&self) -> f32; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Torus; - "#, r#" @@ -3770,12 +4332,6 @@ struct Triangle3d { derive(clone), remote = "bevy::math::bounding::RayCast2d", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::bounding::RayCast2d; - -"#, - r#" /// Construct a [`RayCast2d`] from an origin, [`Dir2`], and max distance. #[lua(kind = "Function", output(proxy))] @@ -3827,6 +4383,12 @@ struct Triangle3d { circle: &bounding::bounded2d::BoundingCircle, ) -> std::option::Option; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::bounding::RayCast2d; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4125,58 +4687,91 @@ struct BoundingSphereCast { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::FloatOrd", + remote = "bevy::math::curve::interval::Interval", functions[r#" +/// Get the start of this interval. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn lt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn start(self) -> f32; "#, r#" +/// Get the end of this interval. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn le(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn end(self) -> f32; "#, r#" +/// Get the length of this interval. Note that the result may be infinite (`f32::INFINITY`). - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn gt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn length(self) -> f32; "#, r#" +/// Returns `true` if this interval is bounded — that is, if both its start and end are finite. +/// Equivalently, an interval is bounded if its length is finite. - #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] - fn ge(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn is_bounded(self) -> bool; "#, r#" +/// Returns `true` if this interval has a finite start. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + #[lua(kind = "Method")] + fn has_finite_start(self) -> bool; + +"#, + r#" +/// Returns `true` if this interval has a finite end. + + #[lua(kind = "Method")] + fn has_finite_end(self) -> bool; + +"#, + r#" +/// Returns `true` if `item` is contained in this interval. + + #[lua(kind = "Method")] + fn contains(self, item: f32) -> bool; + +"#, + r#" +/// Returns `true` if the other interval is contained in this interval. +/// This is non-strict: each interval will contain itself. + + #[lua(kind = "Method")] + fn contains_interval( + self, + #[proxy] + other: bevy::math::curve::interval::Interval, + ) -> bool; + +"#, + r#" +/// Clamp the given `value` to lie within this interval. + + #[lua(kind = "Method")] + fn clamp(self, value: f32) -> f32; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "eq", + metamethod = "Eq", )] - fn neg(self) -> bevy::math::FloatOrd; + fn eq(&self, #[proxy] other: &curve::interval::Interval) -> bool; "#, r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::FloatOrd; + fn clone(&self) -> bevy::math::curve::interval::Interval; "#, r#" @@ -4186,50 +4781,39 @@ fn index(&self) -> String { } "#] )] -struct FloatOrd(f32); +struct Interval {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::math::primitives::Annulus", + remote = "bevy::math::FloatOrd", functions[r#" -/// Create a new [`Annulus`] from the radii of the inner and outer circle - #[lua(kind = "Function", output(proxy))] - fn new(inner_radius: f32, outer_radius: f32) -> bevy::math::primitives::Annulus; + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::FloatOrd; "#, r#" -/// Get the diameter of the annulus - #[lua(kind = "Method")] - fn diameter(&self) -> f32; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn lt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" -/// Get the thickness of the annulus - #[lua(kind = "Method")] - fn thickness(&self) -> f32; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn le(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" -/// Finds the point on the annulus that is closest to the given `point`: -/// - If the point is outside of the annulus completely, the returned point will be on the outer perimeter. -/// - If the point is inside of the inner circle (hole) of the annulus, the returned point will be on the inner perimeter. -/// - Otherwise, the returned point is overlapping the annulus and returned as is. - #[lua(kind = "Method", output(proxy))] - fn closest_point( - &self, - #[proxy] - point: bevy::math::prelude::Vec2, - ) -> bevy::math::prelude::Vec2; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn gt(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Annulus; + #[lua(as_trait = "std::cmp::PartialOrd", kind = "Method")] + fn ge(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; "#, r#" @@ -4240,7 +4824,19 @@ struct FloatOrd(f32); composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &primitives::dim2::Annulus) -> bool; + fn eq(&self, #[proxy] other: &float_ord::FloatOrd) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::FloatOrd; "#, r#" @@ -4250,12 +4846,7 @@ fn index(&self) -> String { } "#] )] -struct Annulus { - #[lua(output(proxy))] - inner_circle: bevy::math::primitives::Circle, - #[lua(output(proxy))] - outer_circle: bevy::math::primitives::Circle, -} +struct FloatOrd(f32); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -4309,23 +4900,6 @@ struct Plane3d { derive(clone), remote = "bevy::math::primitives::Tetrahedron", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &primitives::dim3::Tetrahedron) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::math::primitives::Tetrahedron; - -"#, - r#" /// Create a new [`Tetrahedron`] from points `a`, `b`, `c` and `d`. #[lua(kind = "Function", output(proxy))] @@ -4359,6 +4933,23 @@ struct Plane3d { #[lua(kind = "Method", output(proxy))] fn centroid(&self) -> bevy::math::prelude::Vec3; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::primitives::Tetrahedron; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &primitives::dim3::Tetrahedron) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -4370,6 +4961,35 @@ fn index(&self) -> String { struct Tetrahedron { vertices: ReflectedValue, } +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::curve::easing::EaseFunction", + functions[r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &curve::easing::EaseFunction) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::math::curve::easing::EaseFunction; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct EaseFunction {} #[derive(Default)] pub(crate) struct Globals; impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { @@ -4379,8 +4999,13 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { instances .add_instance( - "AspectRatio", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + "Isometry2d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "Isometry3d", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; instances .add_instance( @@ -4444,6 +5069,11 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Circle", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "Annulus", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Arc2d", @@ -4525,6 +5155,11 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { "Capsule3d", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, )?; + instances + .add_instance( + "Cone", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Segment3d", @@ -4574,11 +5209,6 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { LuaBoundingSphereCast, >::new, )?; - instances - .add_instance( - "Annulus", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; instances .add_instance( "Plane3d", @@ -4614,12 +5244,19 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") + .process_type::() .process_type::() .process_type::() - .process_type::() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaIsometry2d, + >, + >() + .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< - LuaAspectRatio, + LuaIsometry3d, >, >() .process_type::() @@ -4673,6 +5310,10 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -4755,6 +5396,9 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { >, >() .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, + >() .process_type::() .process_type::() .process_type::() @@ -4810,11 +5454,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { LuaBoundingSphereCast, >, >() + .process_type::() .process_type::() - .process_type::() - .process_type::< - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, - >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy, @@ -4825,6 +5466,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { LuaTetrahedron, >, >() + .process_type::() }, ), ) @@ -4845,9 +5487,11 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { Ok(()) } fn register_with_app(&self, app: &mut bevy::app::App) { + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -4861,6 +5505,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -4892,9 +5537,10 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyMathAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); } } diff --git a/crates/bevy_script_api/src/providers/bevy_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs index 357cd406..02453c8d 100644 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ b/crates/bevy_script_api/src/providers/bevy_reflect.rs @@ -8,421 +8,439 @@ use bevy_script_api::{ }; #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( - derive(clone), - remote = "bevy::utils::Duration", + derive(), + remote = "std::sync::atomic::AtomicBool", functions[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. +/// Creates a new `AtomicBool`. /// # Examples /// ``` -/// use std::time::Duration; -/// let five_seconds = Duration::new(5, 0); +/// use std::sync::atomic::AtomicBool; +/// let atomic_true = AtomicBool::new(true); +/// let atomic_false = AtomicBool::new(false); /// ``` #[lua(kind = "Function", output(proxy))] - fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; + fn new(v: bool) -> std::sync::atomic::AtomicBool; "#, r#" -/// Creates a new `Duration` from the specified number of whole seconds. +/// 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::time::Duration; -/// let duration = Duration::from_secs(5); -/// assert_eq!(5, duration.as_secs()); -/// assert_eq!(0, duration.subsec_nanos()); +/// use std::sync::atomic::AtomicBool; +/// let some_bool = AtomicBool::new(true); +/// assert_eq!(some_bool.into_inner(), true); /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_secs(secs: u64) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> bool; "#, r#" -/// Creates a new `Duration` from the specified number of milliseconds. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicBool {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI16", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::from_millis(2569); -/// assert_eq!(2, duration.as_secs()); -/// assert_eq!(569_000_000, duration.subsec_nanos()); +///use std::sync::atomic::AtomicI16; +///let atomic_forty_two = AtomicI16::new(42); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_millis(millis: u64) -> bevy::utils::Duration; + fn new(v: i16) -> std::sync::atomic::AtomicI16; "#, r#" -/// Creates a new `Duration` from the specified number of microseconds. +/// 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::time::Duration; -/// let duration = Duration::from_micros(1_000_002); -/// assert_eq!(1, duration.as_secs()); -/// assert_eq!(2000, duration.subsec_nanos()); +///use std::sync::atomic::AtomicI16; +///let some_var = AtomicI16::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_micros(micros: u64) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> i16; "#, 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. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI16 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI32", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::from_nanos(1_000_000_123); -/// assert_eq!(1, duration.as_secs()); -/// assert_eq!(123, duration.subsec_nanos()); +///use std::sync::atomic::AtomicI32; +///let atomic_forty_two = AtomicI32::new(42); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_nanos(nanos: u64) -> bevy::utils::Duration; + fn new(v: i32) -> std::sync::atomic::AtomicI32; "#, r#" -/// Returns true if this `Duration` spans no time. +/// 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::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()); +///use std::sync::atomic::AtomicI32; +///let some_var = AtomicI32::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` #[lua(kind = "Method")] - fn is_zero(&self) -> bool; + fn into_inner(self) -> i32; "#, 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`]. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI32 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI64", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_secs(), 5); +///use std::sync::atomic::AtomicI64; +///let atomic_forty_two = AtomicI64::new(42); /// ``` -/// 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(kind = "Method")] - fn as_secs(&self) -> u64; + #[lua(kind = "Function", output(proxy))] + fn new(v: i64) -> std::sync::atomic::AtomicI64; "#, 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). +/// 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::time::Duration; -/// let duration = Duration::from_millis(5432); -/// assert_eq!(duration.as_secs(), 5); -/// assert_eq!(duration.subsec_millis(), 432); +///use std::sync::atomic::AtomicI64; +///let some_var = AtomicI64::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` #[lua(kind = "Method")] - fn subsec_millis(&self) -> u32; + fn into_inner(self) -> i64; "#, 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). +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI64 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicI8", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::from_micros(1_234_567); -/// assert_eq!(duration.as_secs(), 1); -/// assert_eq!(duration.subsec_micros(), 234_567); +///use std::sync::atomic::AtomicI8; +///let atomic_forty_two = AtomicI8::new(42); /// ``` - #[lua(kind = "Method")] - fn subsec_micros(&self) -> u32; + #[lua(kind = "Function", output(proxy))] + fn new(v: i8) -> std::sync::atomic::AtomicI8; "#, 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). +/// 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::time::Duration; -/// let duration = Duration::from_millis(5010); -/// assert_eq!(duration.as_secs(), 5); -/// assert_eq!(duration.subsec_nanos(), 10_000_000); +///use std::sync::atomic::AtomicI8; +///let some_var = AtomicI8::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` #[lua(kind = "Method")] - fn subsec_nanos(&self) -> u32; + fn into_inner(self) -> i8; "#, r#" -/// Returns the total number of whole milliseconds contained by this `Duration`. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicI8 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicIsize", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_millis(), 5730); +///use std::sync::atomic::AtomicIsize; +///let atomic_forty_two = AtomicIsize::new(42); /// ``` - #[lua(kind = "Method")] - fn as_millis(&self) -> u128; + #[lua(kind = "Function", output(proxy))] + fn new(v: isize) -> std::sync::atomic::AtomicIsize; "#, r#" -/// Returns the total number of whole microseconds contained by this `Duration`. +/// 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::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_micros(), 5730023); +///use std::sync::atomic::AtomicIsize; +///let some_var = AtomicIsize::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` #[lua(kind = "Method")] - fn as_micros(&self) -> u128; + fn into_inner(self) -> isize; "#, r#" -/// Returns the total number of nanoseconds contained by this `Duration`. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicIsize {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU16", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let duration = Duration::new(5, 730023852); -/// assert_eq!(duration.as_nanos(), 5730023852); +///use std::sync::atomic::AtomicU16; +///let atomic_forty_two = AtomicU16::new(42); /// ``` - #[lua(kind = "Method")] - fn as_nanos(&self) -> u128; + #[lua(kind = "Function", output(proxy))] + fn new(v: u16) -> std::sync::atomic::AtomicU16; "#, r#" -/// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] -/// if overflow occurred. +/// 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 /// ``` -/// #![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); +///use std::sync::atomic::AtomicU16; +///let some_var = AtomicU16::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_add( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> u16; "#, r#" -/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`] -/// if the result would be negative or if overflow occurred. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU16 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU32", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::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); +///use std::sync::atomic::AtomicU32; +///let atomic_forty_two = AtomicU32::new(42); /// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_sub( - self, - #[proxy] - rhs: bevy::utils::Duration, - ) -> bevy::utils::Duration; + #[lua(kind = "Function", output(proxy))] + fn new(v: u32) -> std::sync::atomic::AtomicU32; "#, r#" -/// Saturating `Duration` multiplication. Computes `self * other`, returning -/// [`Duration::MAX`] if overflow occurred. +/// 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 /// ``` -/// #![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); +///use std::sync::atomic::AtomicU32; +///let some_var = AtomicU32::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> u32; "#, r#" -/// Returns the number of seconds contained by this `Duration` as `f64`. -/// The returned value does include the fractional (nanosecond) part of the duration. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU32 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU64", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.as_secs_f64(), 2.7); +///use std::sync::atomic::AtomicU64; +///let atomic_forty_two = AtomicU64::new(42); /// ``` - #[lua(kind = "Method")] - fn as_secs_f64(&self) -> f64; + #[lua(kind = "Function", output(proxy))] + fn new(v: u64) -> std::sync::atomic::AtomicU64; "#, r#" -/// Returns the number of seconds contained by this `Duration` as `f32`. -/// The returned value does include the fractional (nanosecond) part of the duration. +/// 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::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.as_secs_f32(), 2.7); +///use std::sync::atomic::AtomicU64; +///let some_var = AtomicU64::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` #[lua(kind = "Method")] - fn as_secs_f32(&self) -> f32; + fn into_inner(self) -> u64; "#, 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. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU64 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicU8", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::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)); +///use std::sync::atomic::AtomicU8; +///let atomic_forty_two = AtomicU8::new(42); /// ``` #[lua(kind = "Function", output(proxy))] - fn from_secs_f64(secs: f64) -> bevy::utils::Duration; + fn new(v: u8) -> std::sync::atomic::AtomicU8; "#, 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(kind = "Function", output(proxy))] - fn from_secs_f32(secs: f32) -> bevy::utils::Duration; - -"#, - 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(kind = "Method", output(proxy))] - fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; - -"#, - r#" -/// Multiplies `Duration` by `f32`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. +/// 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::time::Duration; -/// let dur = Duration::new(2, 700_000_000); -/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641)); -/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0)); +///use std::sync::atomic::AtomicU8; +///let some_var = AtomicU8::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` - #[lua(kind = "Method", output(proxy))] - fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> u8; "#, r#" -/// Divide `Duration` by `f64`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicU8 {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(), + remote = "std::sync::atomic::AtomicUsize", + functions[r#" +/// Creates a new atomic integer. /// # Examples /// ``` -/// use std::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)); +///use std::sync::atomic::AtomicUsize; +///let atomic_forty_two = AtomicUsize::new(42); /// ``` - #[lua(kind = "Method", output(proxy))] - fn div_f64(self, rhs: f64) -> bevy::utils::Duration; + #[lua(kind = "Function", output(proxy))] + fn new(v: usize) -> std::sync::atomic::AtomicUsize; "#, r#" -/// Divide `Duration` by `f32`. -/// # Panics -/// This method will panic if result is negative, overflows `Duration` or not finite. +/// 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::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)); +///use std::sync::atomic::AtomicUsize; +///let some_var = AtomicUsize::new(5); +/// assert_eq!(some_var.into_inner(), 5); /// ``` - #[lua(kind = "Method", output(proxy))] - fn div_f32(self, rhs: f32) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn into_inner(self) -> usize; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct AtomicUsize {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::utils::Duration", + functions[r#" #[lua( as_trait = "std::ops::Div", @@ -437,23 +455,17 @@ use bevy_script_api::{ r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "add", - metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + fn clone(&self) -> bevy::utils::Duration; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Duration; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -467,24 +479,6 @@ use bevy_script_api::{ )] fn sub(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::utils::Duration; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -498,101 +492,593 @@ use bevy_script_api::{ "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct Duration {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::utils::Instant", - functions[r#" +/// 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( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::utils::Instant; + #[lua(kind = "Function", output(proxy))] + fn new(secs: u64, nanos: u32) -> bevy::utils::Duration; "#, 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( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + #[lua(kind = "Function", output(proxy))] + fn from_secs(secs: u64) -> bevy::utils::Duration; "#, 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(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn from_millis(millis: u64) -> bevy::utils::Duration; "#, 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. +/// 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( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + #[lua(kind = "Function", output(proxy))] + fn from_micros(micros: u64) -> bevy::utils::Duration; "#, r#" -/// Returns an instant corresponding to "now". +/// 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::Instant; -/// let now = Instant::now(); +/// 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(kind = "Function", output(proxy))] - fn now() -> bevy::utils::Instant; + fn from_nanos(nanos: u64) -> bevy::utils::Duration; "#, r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. -/// # Panics -/// Previous Rust versions panicked when `earlier` was later than `self`. Currently this -/// method saturates. Future versions may reintroduce the panic in some circumstances. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity +/// Returns true if this `Duration` spans no time. /// # 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 +/// ``` +/// 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(kind = "Method", output(proxy))] - fn duration_since( - &self, - #[proxy] - earlier: bevy::utils::Instant, - ) -> bevy::utils::Duration; + #[lua(kind = "Method")] + fn is_zero(&self) -> bool; "#, r#" -/// Returns the amount of time elapsed from another instant to this one, +/// 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(kind = "Method")] + fn as_secs(&self) -> 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(kind = "Method")] + fn subsec_millis(&self) -> 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(kind = "Method")] + fn subsec_micros(&self) -> 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(kind = "Method")] + fn subsec_nanos(&self) -> 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(kind = "Method")] + fn as_millis(&self) -> 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(kind = "Method")] + fn as_micros(&self) -> 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(kind = "Method")] + fn as_nanos(&self) -> u128; + +"#, + r#" +/// Computes the absolute difference between `self` and `other`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0)); +/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000)); +/// ``` + + #[lua(kind = "Method", output(proxy))] + fn abs_diff(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Duration; + +"#, + r#" +/// Saturating `Duration` addition. Computes `self + other`, returning [`Duration::MAX`] +/// 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(kind = "Method", output(proxy))] + fn saturating_add( + self, + #[proxy] + rhs: bevy::utils::Duration, + ) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn saturating_sub( + self, + #[proxy] + rhs: bevy::utils::Duration, + ) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn saturating_mul(self, rhs: u32) -> bevy::utils::Duration; + +"#, + 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(kind = "Method")] + fn as_secs_f64(&self) -> 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(kind = "Method")] + fn as_secs_f32(&self) -> 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(kind = "Function", output(proxy))] + fn from_secs_f64(secs: f64) -> bevy::utils::Duration; + +"#, + 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(kind = "Function", output(proxy))] + fn from_secs_f32(secs: f32) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_f64(self, rhs: f64) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn mul_f32(self, rhs: f32) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn div_f64(self, rhs: f64) -> bevy::utils::Duration; + +"#, + 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(kind = "Method", output(proxy))] + fn div_f32(self, rhs: f32) -> bevy::utils::Duration; + +"#, + 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(kind = "Method")] + fn div_duration_f64(self, #[proxy] rhs: bevy::utils::Duration) -> f64; + +"#, + r#" +/// Divides `Duration` by `Duration` and returns `f32`. +/// # Examples +/// ``` +/// use std::time::Duration; +/// let dur1 = Duration::new(2, 700_000_000); +/// let dur2 = Duration::new(5, 400_000_000); +/// assert_eq!(dur1.div_duration_f32(dur2), 0.5); +/// ``` + + #[lua(kind = "Method")] + fn div_duration_f32(self, #[proxy] rhs: bevy::utils::Duration) -> f32; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::utils::Duration) -> bevy::utils::Duration; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::utils::Duration; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Duration {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::utils::Instant", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::utils::Instant; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; + +"#, + 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", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; + +"#, + r#" +/// Returns an instant corresponding to "now". +/// # Examples +/// ``` +/// use std::time::Instant; +/// let now = Instant::now(); +/// ``` + + #[lua(kind = "Function", output(proxy))] + fn now() -> bevy::utils::Instant; + +"#, + 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(kind = "Method", output(proxy))] + fn duration_since( + &self, + #[proxy] + earlier: bevy::utils::Instant, + ) -> bevy::utils::Duration; + +"#, + r#" +/// Returns the amount of time elapsed from another instant to this one, /// or zero duration if that instant is later than this one. /// # Examples /// ```no_run @@ -635,33 +1121,18 @@ struct Duration {} "#, r#" -/// Returns the amount of time elapsed from another instant to this one, -/// or zero duration if that instant is later than this one. /// # Panics -/// Previous Rust versions panicked when `other` was later than `self`. Currently this -/// method saturates. Future versions may reintroduce the panic in some circumstances. -/// See [Monotonicity]. -/// [Monotonicity]: Instant#monotonicity +/// This function may panic if the resulting point in time cannot be represented by the +/// underlying data structure. See [`Instant::checked_add`] for a version without panic. #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] other: bevy::utils::Instant) -> bevy::utils::Duration; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &bevy_utils::Instant) -> bool; + fn add(self, #[proxy] other: bevy::utils::Duration) -> bevy::utils::Instant; "#, r#" @@ -679,23 +1150,12 @@ struct Instant(); functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> std::path::PathBuf; - -"#, - r#" -/// Clones the contents of `source` into `self`. -/// This method is preferred over simply assigning `source.clone()` to `self`, -/// as it avoids reallocation if possible. - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "MutatingMethod", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); + fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; "#, r#" @@ -794,46 +1254,6 @@ struct Instant(); #[lua(kind = "MutatingMethod")] fn shrink_to(&mut self, min_capacity: usize) -> (); -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::path::PathBuf) -> bool; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct PathBuf {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "std::ops::RangeFull", - functions[r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; - "#, r#" @@ -842,61 +1262,47 @@ struct PathBuf {} kind = "Method", output(proxy), )] - fn clone(&self) -> std::ops::RangeFull; + fn clone(&self) -> std::path::PathBuf; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct RangeFull {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Quat", - functions[r#" +/// Clones the contents of `source` into `self`. +/// This method is preferred over simply assigning `source.clone()` to `self`, +/// as it avoids reallocation if possible. #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "MutatingMethod", )] - fn neg(self) -> bevy::math::Quat; + fn clone_from(&mut self, #[proxy] source: &std::path::PathBuf) -> (); "#, r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct PathBuf {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "std::ops::RangeFull", + functions[r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Quat; + fn clone(&self) -> std::ops::RangeFull; "#, r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -907,10 +1313,25 @@ struct RangeFull {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + fn eq(&self, #[proxy] other: &std::ops::RangeFull) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct RangeFull {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Quat", + functions[r#" +/// 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", @@ -919,17 +1340,7 @@ struct RangeFull {} composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Quat; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -1019,6 +1430,10 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] mat: &glam::Mat3) -> bevy::math::Quat; @@ -1026,13 +1441,22 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 SIMD aligned rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3a(#[proxy] mat: &glam::Mat3A) -> bevy::math::Quat; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] mat: &glam::Mat4) -> bevy::math::Quat; @@ -1106,7 +1530,7 @@ struct RangeFull {} /// Returns the rotation angles for the given euler rotation sequence. #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f32, f32, f32); + fn to_euler(self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); "#, r#" @@ -1194,6 +1618,7 @@ struct RangeFull {} "#, r#" +/// Returns `true` if any elements are `NAN`. #[lua(kind = "Method")] fn is_nan(self) -> bool; @@ -1223,6 +1648,24 @@ struct RangeFull {} #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::Quat) -> f32; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::Quat, + max_angle: f32, + ) -> bevy::math::Quat; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -1283,104 +1726,283 @@ struct RangeFull {} "#, r#" /// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn from_affine3(#[proxy] a: &glam::Affine3A) -> bevy::math::Quat; "#, r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. + + #[lua(kind = "Method", output(proxy))] + fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua(kind = "Method", output(proxy))] + fn as_dquat(self) -> bevy::math::DQuat; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Quat) -> bool; + +"#, + r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" +/// Multiplies two quaternions. If they each represent a rotation, the result will +/// represent the combined rotation. +/// Note that due to floating point rounding the result may not be perfectly +/// normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Quat; + +"#, + r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Quat; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Quat(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn mul_vec3a(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua(kind = "Method", output(proxy))] - fn as_dquat(self) -> bevy::math::DQuat; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" - #[lua(kind = "Method", output(proxy))] - fn as_f64(self) -> bevy::math::DQuat; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, rhs: f32) -> bevy::math::Quat; + fn add(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn add(self, rhs: f32) -> bevy::math::Vec3; "#, 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", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::Quat) -> bevy::math::Quat; + fn div(self, #[proxy] rhs: &glam::Vec3) -> bevy::math::Vec3; "#, r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct Quat(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::Vec3", - functions[r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -1646,6 +2268,14 @@ struct Quat(); #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -1656,7 +2286,7 @@ struct Quat(); "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3; @@ -1716,10 +2346,10 @@ struct Quat(); "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec3; @@ -1915,23 +2545,27 @@ struct Quat(); "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3; @@ -1956,7 +2590,30 @@ struct Quat(); "#, r#" -/// Returns the angle (in radians) between two vectors. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec3) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec3, eta: f32) -> bevy::math::Vec3; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. /// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] @@ -2021,48 +2678,35 @@ struct Quat(); r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; + fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, rhs: f32) -> bevy::math::Vec3; + fn neg(self) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "div", - metamethod = "Div", )] - fn div(self, rhs: f32) -> bevy::math::Vec3; + fn clone(&self) -> bevy::math::Vec3; "#, r#" @@ -2076,18 +2720,6 @@ struct Quat(); )] fn mul(self, rhs: f32) -> bevy::math::Vec3; -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - "#, r#" @@ -2104,25 +2736,12 @@ struct Quat(); r#" #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", + composite = "eq", + metamethod = "Eq", )] - fn add(self, rhs: f32) -> bevy::math::Vec3; + fn eq(&self, #[proxy] other: &glam::Vec3) -> bool; "#, r#" @@ -2134,47 +2753,25 @@ struct Quat(); composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: f32) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec3; + fn rem(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn div(self, rhs: f32) -> bevy::math::Vec3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -2190,52 +2787,16 @@ fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f32) -> Res } "#] )] -struct Vec3 { - x: f32, - y: f32, - z: f32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec2", - functions[r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" +struct Vec3 { + x: f32, + y: f32, + z: f32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::IVec2", + functions[r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -2663,13 +3224,13 @@ struct Vec3 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, rhs: i32) -> bevy::math::IVec2; + fn add(self, rhs: i32) -> bevy::math::IVec2; "#, r#" @@ -2681,7 +3242,73 @@ struct Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn div(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -2695,6 +3322,18 @@ struct Vec3 { )] fn rem(self, rhs: i32) -> bevy::math::IVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + "#, r#" @@ -2707,6 +3346,89 @@ struct Vec3 { )] fn sub(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::IVec2) -> bevy::math::IVec2; + "#, r#" @@ -2717,6 +3439,56 @@ struct Vec3 { )] fn clone(&self) -> bevy::math::IVec2; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct IVec2 { + x: i32, + y: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::IVec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; + "#, r#" @@ -2727,42 +3499,65 @@ struct Vec3 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: i32) -> bevy::math::IVec2; + fn div(self, rhs: i32) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "div", + metamethod = "Div", )] - fn neg(self) -> bevy::math::IVec2; + fn div(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "add", - metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::IVec2; + fn clone(&self) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::IVec2) -> bool; + fn neg(self) -> bevy::math::IVec3; "#, r#" @@ -2774,74 +3569,37 @@ struct Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: i32) -> bevy::math::IVec2; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct IVec2 { - x: i32, - y: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::IVec3", - functions[r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::IVec3; + fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::IVec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: i32) -> bevy::math::IVec3; + fn sub(self, rhs: i32) -> bevy::math::IVec3; "#, r#" @@ -3283,31 +4041,19 @@ struct IVec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn add(self, rhs: i32) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, rhs: i32) -> bevy::math::IVec3; + fn mul(self, rhs: i32) -> bevy::math::IVec3; "#, r#" @@ -3325,48 +4071,37 @@ struct IVec2 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; + fn rem(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: i32) -> bevy::math::IVec3; + fn add(self, #[proxy] rhs: &glam::IVec3) -> bevy::math::IVec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::IVec3) -> bool; + fn add(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; "#, r#" @@ -3380,29 +4115,11 @@ struct IVec2 { )] fn div(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::IVec3; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -3429,30 +4146,6 @@ struct IVec3 { remote = "bevy::math::IVec4", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::IVec4; - -"#, - r#" - #[lua( as_trait = "std::ops::Rem", kind = "MetaFunction", @@ -3466,36 +4159,11 @@ struct IVec3 { r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: i32) -> bevy::math::IVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "div", - metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn clone(&self) -> bevy::math::IVec4; "#, r#" @@ -3507,31 +4175,31 @@ struct IVec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i32) -> bevy::math::IVec4; + fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn mul(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: i32) -> bevy::math::IVec4; + fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" @@ -3953,41 +4621,85 @@ struct IVec3 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i32) -> bevy::math::IVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::IVec4; + fn add(self, rhs: i32) -> bevy::math::IVec4; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; + fn div(self, rhs: i32) -> bevy::math::IVec4; "#, r#" @@ -4003,54 +4715,27 @@ struct IVec3 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#, - r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} -"#, - r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct IVec4 { - x: i32, - y: i32, - z: i32, - w: i32, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec2", - functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "neg", + metamethod = "Unm", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn neg(self) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::I64Vec2; + fn add(self, #[proxy] rhs: &glam::IVec4) -> bevy::math::IVec4; "#, r#" @@ -4062,45 +4747,68 @@ struct IVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + fn sub(self, rhs: i32) -> bevy::math::IVec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn eq(&self, #[proxy] other: &glam::IVec4) -> bool; "#, r#" - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: i64) -> bevy::math::I64Vec2; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: i32) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct IVec4 { + x: i32, + y: i32, + z: i32, + w: i32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::I64Vec2", + functions[r#" /// Creates a new vector. #[lua(kind = "Function", output(proxy))] @@ -4542,7 +5250,100 @@ struct IVec4 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn add(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" @@ -4554,79 +5355,115 @@ struct IVec4 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec2; + fn add(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec2; + fn rem(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec2; + fn add(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::I64Vec2; + fn mul(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec2) -> bevy::math::I64Vec2; + fn div(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -4641,11 +5478,13 @@ struct I64Vec2 { functions[r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::I64Vec3; + fn sub(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -4657,7 +5496,7 @@ struct I64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn div(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -4669,19 +5508,7 @@ struct I64Vec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn rem(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -4693,49 +5520,37 @@ struct I64Vec2 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: i64) -> bevy::math::I64Vec3; + fn div(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::I64Vec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, rhs: i64) -> bevy::math::I64Vec3; + fn add(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn sub(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; "#, r#" @@ -4752,13 +5567,25 @@ struct I64Vec2 { r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "neg", + metamethod = "Unm", )] - fn sub(self, rhs: i64) -> bevy::math::I64Vec3; + fn neg(self) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -5198,6 +6025,18 @@ struct I64Vec2 { rhs: bevy::math::U64Vec3, ) -> bevy::math::I64Vec3; +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: i64) -> bevy::math::I64Vec3; + "#, r#" @@ -5208,7 +6047,19 @@ struct I64Vec2 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec3; + fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: i64) -> bevy::math::I64Vec3; "#, r#" @@ -5220,46 +6071,133 @@ struct I64Vec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn add(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::I64Vec3) -> bevy::math::I64Vec3; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct I64Vec3 { + x: i64, + y: i64, + z: i64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::I64Vec4", + functions[r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "rem", - metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::I64Vec3) -> bevy::math::I64Vec3; + fn clone(&self) -> bevy::math::I64Vec4; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct I64Vec3 { - x: i64, - y: i64, - z: i64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::I64Vec4", - functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Neg", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + fn neg(self) -> bevy::math::I64Vec4; "#, r#" @@ -5685,18 +6623,6 @@ struct I64Vec3 { rhs: bevy::math::U64Vec4, ) -> bevy::math::I64Vec4; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; - "#, r#" @@ -5707,7 +6633,7 @@ struct I64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: i64) -> bevy::math::I64Vec4; + fn add(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -5721,12 +6647,6 @@ struct I64Vec3 { )] fn rem(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -5749,31 +6669,31 @@ struct I64Vec3 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + fn rem(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn sub(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::I64Vec4; + fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -5803,13 +6723,36 @@ struct I64Vec3 { r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::I64Vec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + fn rem(self, rhs: i64) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; "#, r#" @@ -5827,17 +6770,31 @@ struct I64Vec3 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::I64Vec4; + fn sub(self, #[proxy] rhs: bevy::math::I64Vec4) -> bevy::math::I64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::I64Vec4) -> bevy::math::I64Vec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -5854,37 +6811,36 @@ struct I64Vec4 { functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "add", + metamethod = "Add", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, rhs: u32) -> bevy::math::UVec2; + fn sub(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "eq", + metamethod = "Eq", )] - fn rem(self, rhs: u32) -> bevy::math::UVec2; + fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; "#, r#" @@ -5898,6 +6854,28 @@ struct I64Vec4 { )] fn sub(self, rhs: u32) -> bevy::math::UVec2; +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + "#, r#" @@ -5910,6 +6888,18 @@ struct I64Vec4 { )] fn add(self, rhs: u32) -> bevy::math::UVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; + "#, r#" @@ -5920,18 +6910,31 @@ struct I64Vec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u32) -> bevy::math::UVec2; + fn div(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &glam::UVec2) -> bool; + fn mul(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u32) -> bevy::math::UVec2; "#, r#" @@ -5939,6 +6942,42 @@ struct I64Vec4 { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; + "#, r#" /// Creates a new vector. @@ -6265,18 +7304,6 @@ struct I64Vec4 { #[lua(kind = "Method", output(proxy))] fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec2) -> bevy::math::UVec2; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - "#, r#" @@ -6293,41 +7320,31 @@ struct I64Vec4 { r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; + fn mul(self, #[proxy] rhs: &glam::UVec2) -> bevy::math::UVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::UVec2; + fn mul(self, #[proxy] rhs: bevy::math::UVec2) -> bevy::math::UVec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -6353,18 +7370,6 @@ struct UVec2 { remote = "bevy::math::UVec3", functions[r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - #[lua( as_trait = "std::ops::Div", kind = "MetaFunction", @@ -6372,89 +7377,7 @@ struct UVec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: u32) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + fn div(self, rhs: u32) -> bevy::math::UVec3; "#, r#" @@ -6468,23 +7391,17 @@ struct UVec2 { )] fn mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: u32) -> bevy::math::UVec3; + fn sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" @@ -6779,84 +7696,244 @@ struct UVec2 { "#, 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), ..]`. +/// Returns a vector containing the wrapping multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the wrapping division of `self` and `rhs`. +/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating subtraction of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating multiplication of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating division of `self` and `rhs`. +/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u32) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn wrapping_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" -/// Returns a vector containing the wrapping division of `self` and `rhs`. -/// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; "#, r#" -/// Returns a vector containing the saturating addition of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_add(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" -/// Returns a vector containing the saturating subtraction of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_sub(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; "#, r#" -/// Returns a vector containing the saturating multiplication of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_mul(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u32) -> bevy::math::UVec3; "#, r#" -/// Returns a vector containing the saturating division of `self` and `rhs`. -/// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_div(self, #[proxy] rhs: bevy::math::UVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" -/// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. -/// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" -/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. -/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec3) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Rem", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn eq(&self, #[proxy] other: &glam::UVec3) -> bool; + fn rem(self, #[proxy] rhs: &glam::UVec3) -> bevy::math::UVec3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -6884,48 +7961,37 @@ struct UVec3 { functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: u32) -> bevy::math::UVec4; + fn sub(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" @@ -6943,53 +8009,25 @@ struct UVec3 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, rhs: u32) -> bevy::math::UVec4; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn rem(self, rhs: u32) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn add(self, rhs: u32) -> bevy::math::UVec4; "#, r#" @@ -7321,28 +8359,121 @@ struct UVec3 { /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`. /// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; + #[lua(kind = "Method", output(proxy))] + fn wrapping_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; + +"#, + r#" +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::UVec4) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u32) -> bevy::math::UVec4; "#, r#" -/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. -/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. - #[lua(kind = "Method", output(proxy))] - fn saturating_add_signed(self, #[proxy] rhs: bevy::math::IVec4) -> bevy::math::UVec4; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn div(self, rhs: u32) -> bevy::math::UVec4; "#, r#" @@ -7354,25 +8485,31 @@ struct UVec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: u32) -> bevy::math::UVec4; + fn mul(self, #[proxy] rhs: &glam::UVec4) -> bevy::math::UVec4; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; + fn div(self, #[proxy] rhs: bevy::math::UVec4) -> bevy::math::UVec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -7401,22 +8538,37 @@ struct UVec4 { functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Sub", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + fn sub(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::U64Vec2; + fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: u64) -> bevy::math::U64Vec2; "#, r#" @@ -7428,7 +8580,19 @@ struct UVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; "#, r#" @@ -7436,6 +8600,42 @@ struct UVec4 { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec2; + "#, r#" /// Creates a new vector. @@ -7770,6 +8970,150 @@ struct UVec4 { rhs: bevy::math::I64Vec2, ) -> bevy::math::U64Vec2; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::U64Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::U64Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct U64Vec2 { + x: u64, + y: u64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::U64Vec3", + functions[r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; + "#, r#" @@ -7780,31 +9124,31 @@ struct UVec4 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn add(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "mul", + metamethod = "Mul", )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec2; + fn mul(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn div(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -7816,19 +9160,19 @@ struct UVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec2; + fn div(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "rem", + metamethod = "Mod", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec2; + fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" @@ -7840,19 +9184,13 @@ struct UVec4 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -7864,56 +9202,19 @@ struct UVec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec2) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec2; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct U64Vec2 { - x: u64, - y: u64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::U64Vec3", - functions[r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::U64Vec3; + fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn rem(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" @@ -7925,79 +9226,76 @@ struct U64Vec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: u64) -> bevy::math::U64Vec3; + fn rem(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec3; + fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn add(self, #[proxy] rhs: &glam::U64Vec3) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec3; + fn sub(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn mul(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "add", - metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; + fn clone(&self) -> bevy::math::U64Vec3; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec3; + fn mul(self, rhs: u64) -> bevy::math::U64Vec3; "#, r#" @@ -8362,52 +9660,11 @@ struct U64Vec2 { rhs: bevy::math::I64Vec3, ) -> bevy::math::U64Vec3; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::U64Vec3) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: u64) -> bevy::math::U64Vec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::U64Vec3) -> bevy::math::U64Vec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -8423,25 +9680,25 @@ struct U64Vec3 { functions[r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn div(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, rhs: u64) -> bevy::math::U64Vec4; + fn div(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -8455,17 +9712,35 @@ struct U64Vec3 { )] fn sub(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "rem", + metamethod = "Mod", )] - fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn rem(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" @@ -8477,6 +9752,18 @@ struct U64Vec3 { )] fn clone(&self) -> bevy::math::U64Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: u64) -> bevy::math::U64Vec4; + "#, r#" /// Creates a new vector. @@ -8816,26 +10103,51 @@ struct U64Vec3 { "#, r#" -/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. -/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. +/// Returns a vector containing the saturating addition of `self` and signed vector `rhs`. +/// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`. + + #[lua(kind = "Method", output(proxy))] + fn saturating_add_signed( + self, + #[proxy] + rhs: bevy::math::I64Vec4, + ) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn saturating_add_signed( - self, - #[proxy] - rhs: bevy::math::I64Vec4, - ) -> bevy::math::U64Vec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; + fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -8847,31 +10159,30 @@ struct U64Vec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: u64) -> bevy::math::U64Vec4; + fn add(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: u64) -> bevy::math::U64Vec4; + fn sub(self, rhs: u64) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", + composite = "eq", + metamethod = "Eq", )] - fn add(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn eq(&self, #[proxy] other: &glam::U64Vec4) -> bool; "#, r#" @@ -8888,8 +10199,14 @@ struct U64Vec3 { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; "#, r#" @@ -8901,25 +10218,25 @@ struct U64Vec3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::U64Vec4) -> bevy::math::U64Vec4; + fn mul(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, rhs: u64) -> bevy::math::U64Vec4; + fn sub(self, #[proxy] rhs: &glam::U64Vec4) -> bevy::math::U64Vec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -8936,37 +10253,49 @@ struct U64Vec4 { functions[r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "rem", + metamethod = "Mod", )] - fn add(self, rhs: f32) -> bevy::math::Vec2; + fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, rhs: f32) -> bevy::math::Vec2; + fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec2; "#, r#" @@ -8978,7 +10307,55 @@ struct U64Vec4 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn div(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; "#, r#" @@ -8990,6 +10367,53 @@ struct U64Vec4 { )] fn clone(&self) -> bevy::math::Vec2; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f32) -> bevy::math::Vec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + "#, r#" /// Creates a new vector. @@ -9235,6 +10659,14 @@ struct U64Vec4 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec2; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -9245,7 +10677,7 @@ struct U64Vec4 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec2; @@ -9305,10 +10737,10 @@ struct U64Vec4 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec2; @@ -9504,23 +10936,27 @@ struct U64Vec4 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec2; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec2; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec2; @@ -9543,6 +10979,29 @@ struct U64Vec4 { b: bevy::math::Vec2, ) -> bevy::math::Vec2; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec2) -> bevy::math::Vec2; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec2, eta: f32) -> bevy::math::Vec2; + "#, r#" /// Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in @@ -9563,12 +11022,18 @@ struct U64Vec4 { "#, r#" -/// Returns the angle (in radians) between `self` and `rhs` in the range `[-Ï€, +Ï€]`. -/// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::Vec2) -> f32; +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-Ï€, +Ï€]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua(kind = "Method")] + fn angle_to(self, #[proxy] rhs: bevy::math::Vec2) -> f32; + "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. @@ -9595,109 +11060,89 @@ struct U64Vec4 { "#, r#" -/// Casts all elements of `self` to `f64`. - - #[lua(kind = "Method", output(proxy))] - fn as_dvec2(&self) -> bevy::math::DVec2; - -"#, - r#" -/// Casts all elements of `self` to `i32`. +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. #[lua(kind = "Method", output(proxy))] - fn as_ivec2(&self) -> bevy::math::IVec2; + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::Vec2, + max_angle: f32, + ) -> bevy::math::Vec2; "#, r#" -/// Casts all elements of `self` to `u32`. +/// Casts all elements of `self` to `f64`. #[lua(kind = "Method", output(proxy))] - fn as_uvec2(&self) -> bevy::math::UVec2; + fn as_dvec2(&self) -> bevy::math::DVec2; "#, r#" -/// Casts all elements of `self` to `i64`. +/// Casts all elements of `self` to `i32`. #[lua(kind = "Method", output(proxy))] - fn as_i64vec2(&self) -> bevy::math::I64Vec2; + fn as_ivec2(&self) -> bevy::math::IVec2; "#, r#" -/// Casts all elements of `self` to `u64`. +/// Casts all elements of `self` to `u32`. #[lua(kind = "Method", output(proxy))] - fn as_u64vec2(&self) -> bevy::math::U64Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f32) -> bevy::math::Vec2; + fn as_uvec2(&self) -> bevy::math::UVec2; "#, r#" +/// Casts all elements of `self` to `i64`. - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(kind = "Method", output(proxy))] + fn as_i64vec2(&self) -> bevy::math::I64Vec2; "#, r#" +/// Casts all elements of `self` to `u64`. - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + #[lua(kind = "Method", output(proxy))] + fn as_u64vec2(&self) -> bevy::math::U64Vec2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", )] - fn eq(&self, #[proxy] other: &glam::Vec2) -> bool; + fn add(self, #[proxy] rhs: &glam::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: f32) -> bevy::math::Vec2; + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "rem", + metamethod = "Mod", )] - fn neg(self) -> bevy::math::Vec2; + fn rem(self, rhs: f32) -> bevy::math::Vec2; "#, r#" @@ -9709,25 +11154,13 @@ struct U64Vec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec2; + fn mul(self, rhs: f32) -> bevy::math::Vec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -9753,30 +11186,6 @@ struct Vec2 { remote = "bevy::math::Vec3A", functions[r#" - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - #[lua( as_trait = "std::ops::Sub", kind = "MetaFunction", @@ -9784,67 +11193,18 @@ struct Vec2 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", - output(proxy), - composite = "neg", - metamethod = "Unm", - )] - fn neg(self) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f32) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f32) -> bevy::math::Vec3A; + fn sub(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; "#, r#" @@ -9891,6 +11251,14 @@ struct Vec2 { #[lua(kind = "Method")] fn to_array(&self) -> [f32; 3]; +"#, + r#" +/// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. +/// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. + + #[lua(kind = "Function", output(proxy))] + fn from_vec4(#[proxy] v: bevy::math::Vec4) -> bevy::math::Vec3A; + "#, r#" /// Creates a 4D vector from `self` and the given `w` value. @@ -10113,6 +11481,14 @@ struct Vec2 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3A; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -10123,7 +11499,7 @@ struct Vec2 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3A; @@ -10183,10 +11559,10 @@ struct Vec2 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec3A; @@ -10390,23 +11766,27 @@ struct Vec2 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec3A; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec3A; @@ -10431,87 +11811,233 @@ struct Vec2 { "#, r#" -/// Returns the angle (in radians) between two vectors. -/// The inputs do not need to be unit vectors however they must be non-zero. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec3A, eta: f32) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua(kind = "Method")] + fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + +"#, + r#" +/// Returns some vector that is orthogonal to the given one. +/// The input vector must be finite and non-zero. +/// The output vector is not necessarily unit length. For that use +/// [`Self::any_orthonormal_vector()`] instead. + + #[lua(kind = "Method", output(proxy))] + fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Returns any unit vector that is orthogonal to the given one. +/// The input vector must be unit length. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; + +"#, + r#" +/// Casts all elements of `self` to `f64`. + + #[lua(kind = "Method", output(proxy))] + fn as_dvec3(&self) -> bevy::math::DVec3; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec3(&self) -> bevy::math::IVec3; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec3(&self) -> bevy::math::UVec3; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec3(&self) -> bevy::math::I64Vec3; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec3(&self) -> bevy::math::U64Vec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, rhs: f32) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" - #[lua(kind = "Method")] - fn angle_between(self, #[proxy] rhs: bevy::math::Vec3A) -> f32; + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Returns some vector that is orthogonal to the given one. -/// The input vector must be finite and non-zero. -/// The output vector is not necessarily unit length. For that use -/// [`Self::any_orthonormal_vector()`] instead. - #[lua(kind = "Method", output(proxy))] - fn any_orthogonal_vector(&self) -> bevy::math::Vec3A; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" -/// Returns any unit vector that is orthogonal to the given one. -/// The input vector must be unit length. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua(kind = "Method", output(proxy))] - fn any_orthonormal_vector(&self) -> bevy::math::Vec3A; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Casts all elements of `self` to `f64`. - #[lua(kind = "Method", output(proxy))] - fn as_dvec3(&self) -> bevy::math::DVec3; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" -/// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec3(&self) -> bevy::math::IVec3; + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::Vec3A; "#, r#" -/// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] - fn as_uvec3(&self) -> bevy::math::UVec3; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec3(&self) -> bevy::math::I64Vec3; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" -/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec3(&self) -> bevy::math::U64Vec3; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] rhs: &glam::Vec3A) -> bool; + fn div(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::Vec3A; + fn add(self, rhs: f32) -> bevy::math::Vec3A; "#, r#" @@ -10523,37 +12049,47 @@ struct Vec2 { composite = "rem", metamethod = "Mod", )] - fn rem(self, rhs: f32) -> bevy::math::Vec3A; + fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "sub", + metamethod = "Sub", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn sub(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn mul(self, #[proxy] rhs: &glam::Vec3A) -> bevy::math::Vec3A; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Vec3A; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -10834,6 +12370,14 @@ struct Vec3A(); #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec4A; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -10844,7 +12388,7 @@ struct Vec3A(); "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec4A; @@ -10904,10 +12448,10 @@ struct Vec3A(); "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::Vec4; @@ -11103,23 +12647,27 @@ struct Vec3A(); "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f32, max: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f32) -> bevy::math::Vec4; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f32) -> bevy::math::Vec4; @@ -11142,6 +12690,29 @@ struct Vec3A(); b: bevy::math::Vec4, ) -> bevy::math::Vec4; +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::Vec4, eta: f32) -> bevy::math::Vec4; + "#, r#" /// Casts all elements of `self` to `f64`. @@ -11181,24 +12752,37 @@ struct Vec3A(); r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Rem", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; + fn rem(self, rhs: f32) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn div(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Vec4; "#, r#" @@ -11212,6 +12796,18 @@ struct Vec3A(); )] fn neg(self) -> bevy::math::Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; + "#, r#" @@ -11224,6 +12820,30 @@ struct Vec3A(); )] fn add(self, rhs: f32) -> bevy::math::Vec4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; + "#, r#" @@ -11240,13 +12860,13 @@ struct Vec3A(); r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn sub(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11258,7 +12878,7 @@ struct Vec3A(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn mul(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11274,25 +12894,24 @@ struct Vec3A(); r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", + composite = "eq", + metamethod = "Eq", )] - fn div(self, rhs: f32) -> bevy::math::Vec4; + fn eq(&self, #[proxy] rhs: &glam::Vec4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "add", + metamethod = "Add", )] - fn rem(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" @@ -11304,37 +12923,49 @@ struct Vec3A(); composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Vec4; + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::Vec4) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, rhs: f32) -> bevy::math::Vec4; + fn div(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + fn mul(self, rhs: f32) -> bevy::math::Vec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -11357,27 +12988,6 @@ struct Vec4(); remote = "bevy::math::BVec2", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec2; - -"#, - r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); @@ -11441,11 +13051,32 @@ struct Vec4(); #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11459,17 +13090,6 @@ struct BVec2 { remote = "bevy::math::BVec3", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; - -"#, - r#" - #[lua( as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", kind = "Method", @@ -11477,6 +13097,12 @@ struct BVec2 { )] fn clone(&self) -> bevy::math::BVec3; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" /// Creates a new vector mask. @@ -11540,14 +13166,19 @@ struct BVec2 { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::BVec3) -> bool; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11562,16 +13193,6 @@ struct BVec3 { remote = "bevy::math::BVec4", functions[r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::BVec4; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -11646,11 +13267,21 @@ struct BVec3 { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::BVec4; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -11673,7 +13304,29 @@ struct BVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f64) -> bevy::math::DVec2; + fn mul(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec2; "#, r#" @@ -11687,6 +13340,42 @@ struct BVec4 { )] fn sub(self, rhs: f64) -> bevy::math::DVec2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + "#, r#" @@ -11703,13 +13392,24 @@ struct BVec4 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "sub", + metamethod = "Sub", )] - fn add(self, rhs: f64) -> bevy::math::DVec2; + fn sub(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; "#, r#" @@ -11727,23 +13427,25 @@ struct BVec4 { r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn add(self, rhs: f64) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Div", + kind = "MetaFunction", output(proxy), + composite = "div", + metamethod = "Div", )] - fn clone(&self) -> bevy::math::DVec2; + fn div(self, rhs: f64) -> bevy::math::DVec2; "#, r#" @@ -11761,24 +13463,37 @@ struct BVec4 { r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn mul(self, rhs: f64) -> bevy::math::DVec2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Rem", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "rem", + metamethod = "Mod", )] - fn eq(&self, #[proxy] other: &glam::DVec2) -> bool; + fn rem(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; "#, r#" @@ -12025,6 +13740,14 @@ struct BVec4 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec2; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -12035,7 +13758,7 @@ struct BVec4 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec2; @@ -12095,10 +13818,10 @@ struct BVec4 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec2; @@ -12302,23 +14025,27 @@ struct BVec4 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec2; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec2; @@ -12333,13 +14060,36 @@ struct BVec4 { /// mind. #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec2, - #[proxy] - b: bevy::math::DVec2, - ) -> bevy::math::DVec2; + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec2, + #[proxy] + b: bevy::math::DVec2, + ) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec2, eta: f64) -> bevy::math::DVec2; "#, r#" @@ -12361,12 +14111,18 @@ struct BVec4 { "#, r#" -/// Returns the angle (in radians) between `self` and `rhs` in the range `[-Ï€, +Ï€]`. -/// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::DVec2) -> f64; +"#, + r#" +/// Returns the angle of rotation (in radians) from `self` to `rhs` in the range `[-Ï€, +Ï€]`. +/// The inputs do not need to be unit vectors however they must be non-zero. + + #[lua(kind = "Method")] + fn angle_to(self, #[proxy] rhs: bevy::math::DVec2) -> f64; + "#, r#" /// Returns a vector that is equal to `self` rotated by 90 degrees. @@ -12391,6 +14147,21 @@ struct BVec4 { #[lua(kind = "Method", output(proxy))] fn rotate(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::DVec2, + max_angle: f64, + ) -> bevy::math::DVec2; + "#, r#" /// Casts all elements of `self` to `f32`. @@ -12426,18 +14197,6 @@ struct BVec4 { #[lua(kind = "Method", output(proxy))] fn as_u64vec2(&self) -> bevy::math::U64Vec2; -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; - "#, r#" @@ -12448,25 +14207,13 @@ struct BVec4 { composite = "div", metamethod = "Div", )] - fn div(self, rhs: f64) -> bevy::math::DVec2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn div(self, #[proxy] rhs: &glam::DVec2) -> bevy::math::DVec2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -12492,64 +14239,6 @@ struct DVec2 { remote = "bevy::math::DVec3", functions[r#" - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Rem", - kind = "MetaFunction", - output(proxy), - composite = "rem", - metamethod = "Mod", - )] - fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - #[lua( as_trait = "std::ops::Add", kind = "MetaFunction", @@ -12557,30 +14246,7 @@ struct DVec2 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Div", - kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", - )] - fn div(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + fn add(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" @@ -12592,19 +14258,17 @@ struct DVec2 { composite = "div", metamethod = "Div", )] - fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn div(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + fn clone(&self) -> bevy::math::DVec3; "#, r#" @@ -12622,25 +14286,13 @@ struct DVec2 { r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, rhs: f64) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "rem", + metamethod = "Mod", )] - fn neg(self) -> bevy::math::DVec3; + fn rem(self, rhs: f64) -> bevy::math::DVec3; "#, r#" @@ -12909,6 +14561,14 @@ struct DVec2 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec3; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -12919,7 +14579,7 @@ struct DVec2 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec3; @@ -12979,10 +14639,10 @@ struct DVec2 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec3; @@ -13186,23 +14846,27 @@ struct DVec2 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec3; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec3; @@ -13227,7 +14891,30 @@ struct DVec2 { "#, r#" -/// Returns the angle (in radians) between two vectors. +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec3) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec3, eta: f64) -> bevy::math::DVec3; + +"#, + r#" +/// Returns the angle (in radians) between two vectors in the range `[0, +Ï€]`. /// The inputs do not need to be unit vectors however they must be non-zero. #[lua(kind = "Method")] @@ -13297,42 +14984,63 @@ struct DVec2 { "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + "#, r#" -#[lua(kind="MetaMethod", raw , metamethod="Index")] -fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { - Ok(self.inner()?[*idx]) -} + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + "#, r#" -#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] -fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { - self.val_mut(|s| Ok(s[*idx] = val))? -} -"#] -)] -struct DVec3 { - x: f64, - y: f64, - z: f64, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DVec4", - functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Add", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", )] - fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; + fn neg(self) -> bevy::math::DVec3; "#, r#" @@ -13344,31 +15052,31 @@ struct DVec3 { composite = "sub", metamethod = "Sub", )] - fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn sub(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "div", + metamethod = "Div", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn div(self, rhs: f64) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn sub(self, rhs: f64) -> bevy::math::DVec3; "#, r#" @@ -13380,19 +15088,19 @@ struct DVec3 { composite = "rem", metamethod = "Mod", )] - fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn rem(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f64) -> bevy::math::DVec4; + fn sub(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" @@ -13404,17 +15112,70 @@ struct DVec3 { composite = "add", metamethod = "Add", )] - fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn add(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::DVec4; + fn mul(self, #[proxy] rhs: &glam::DVec3) -> bevy::math::DVec3; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec3) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#, + r#" +#[lua(kind="MetaMethod", raw , metamethod="Index")] +fn index(&self, lua: &Lua, idx: crate::lua::util::LuaIndex) -> Result { + Ok(self.inner()?[*idx]) +} +"#, + r#" +#[lua(kind="MutatingMetaMethod", raw, metamethod="NewIndex")] +fn index(&mut self, lua: &Lua, idx: crate::lua::util::LuaIndex, val: f64) -> Result<(),_> { + self.val_mut(|s| Ok(s[*idx] = val))? +} +"#] +)] +struct DVec3 { + x: f64, + y: f64, + z: f64, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DVec4", + functions[r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DVec4; "#, r#" @@ -13426,43 +15187,53 @@ struct DVec3 { composite = "add", metamethod = "Add", )] - fn add(self, rhs: f64) -> bevy::math::DVec4; + fn add(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, rhs: f64) -> bevy::math::DVec4; + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "rem", + metamethod = "Mod", )] - fn neg(self) -> bevy::math::DVec4; + fn rem(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Rem", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "rem", + metamethod = "Mod", )] - fn mul(self, rhs: f64) -> bevy::math::DVec4; + fn rem(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DVec4; "#, r#" @@ -13724,6 +15495,14 @@ struct DVec3 { #[lua(kind = "Method")] fn is_finite(self) -> bool; +"#, + r#" +/// Performs `is_finite` on each element of self, returning a vector mask of the results. +/// In other words, this computes `[x.is_finite(), y.is_finite(), ...]`. + + #[lua(kind = "Method", output(proxy))] + fn is_finite_mask(self) -> bevy::math::BVec4; + "#, r#" /// Returns `true` if any elements are `NaN`. @@ -13734,7 +15513,7 @@ struct DVec3 { "#, r#" /// Performs `is_nan` on each element of self, returning a vector mask of the results. -/// In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. +/// In other words, this computes `[x.is_nan(), y.is_nan(), ...]`. #[lua(kind = "Method", output(proxy))] fn is_nan_mask(self) -> bevy::math::BVec4; @@ -13794,10 +15573,10 @@ struct DVec3 { "#, r#" /// Returns `self` normalized to length 1.0. -/// For valid results, `self` must _not_ be of length zero, nor very close to zero. +/// For valid results, `self` must be finite and _not_ of length zero, nor very close to zero. /// See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. /// Panics -/// Will panic if `self` is zero length when `glam_assert` is enabled. +/// Will panic if the resulting normalized vector is not finite when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn normalize(self) -> bevy::math::DVec4; @@ -14001,97 +15780,255 @@ struct DVec3 { "#, r#" -/// Returns a vector with a length no less than `min` and no more than `max` +/// Returns a vector with a length no less than `min` and no more than `max`. /// # Panics -/// Will panic if `min` is greater than `max` when `glam_assert` is enabled. +/// Will panic if `min` is greater than `max`, or if either `min` or `max` is negative, when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length(self, min: f64, max: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with a length no more than `max` +/// Returns a vector with a length no more than `max`. +/// # Panics +/// Will panic if `max` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_max(self, max: f64) -> bevy::math::DVec4; "#, r#" -/// Returns a vector with a length no less than `min` +/// Returns a vector with a length no less than `min`. +/// # Panics +/// Will panic if `min` is negative when `glam_assert` is enabled. #[lua(kind = "Method", output(proxy))] fn clamp_length_min(self, min: f64) -> bevy::math::DVec4; "#, 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. +/// Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding +/// error, yielding a more accurate result than an unfused multiply-add. +/// Using `mul_add` *may* be more performant than an unfused multiply-add if the target +/// architecture has a dedicated fma CPU instruction. However, this is not always true, +/// and will be heavily dependant on designing algorithms with specific target hardware in +/// mind. + + #[lua(kind = "Method", output(proxy))] + fn mul_add( + self, + #[proxy] + a: bevy::math::DVec4, + #[proxy] + b: bevy::math::DVec4, + ) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the reflection vector for a given incident vector `self` and surface normal +/// `normal`. +/// `normal` must be normalized. +/// # Panics +/// Will panic if `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn reflect(self, #[proxy] normal: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" +/// Returns the refraction direction for a given incident vector `self`, surface normal +/// `normal` and ratio of indices of refraction, `eta`. When total internal reflection occurs, +/// a zero vector will be returned. +/// `self` and `normal` must be normalized. +/// # Panics +/// Will panic if `self` or `normal` is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn refract(self, #[proxy] normal: bevy::math::DVec4, eta: f64) -> bevy::math::DVec4; + +"#, + r#" +/// Casts all elements of `self` to `f32`. + + #[lua(kind = "Method", output(proxy))] + fn as_vec4(&self) -> bevy::math::Vec4; + +"#, + r#" +/// Casts all elements of `self` to `i32`. + + #[lua(kind = "Method", output(proxy))] + fn as_ivec4(&self) -> bevy::math::IVec4; + +"#, + r#" +/// Casts all elements of `self` to `u32`. + + #[lua(kind = "Method", output(proxy))] + fn as_uvec4(&self) -> bevy::math::UVec4; + +"#, + r#" +/// Casts all elements of `self` to `i64`. + + #[lua(kind = "Method", output(proxy))] + fn as_i64vec4(&self) -> bevy::math::I64Vec4; + +"#, + r#" +/// Casts all elements of `self` to `u64`. + + #[lua(kind = "Method", output(proxy))] + fn as_u64vec4(&self) -> bevy::math::U64Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Rem", + kind = "MetaFunction", + output(proxy), + composite = "rem", + metamethod = "Mod", + )] + fn rem(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, rhs: f64) -> bevy::math::DVec4; + +"#, + r#" - #[lua(kind = "Method", output(proxy))] - fn mul_add( - self, - #[proxy] - a: bevy::math::DVec4, - #[proxy] - b: bevy::math::DVec4, - ) -> bevy::math::DVec4; + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Casts all elements of `self` to `f32`. - #[lua(kind = "Method", output(proxy))] - fn as_vec4(&self) -> bevy::math::Vec4; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &glam::DVec4) -> bool; "#, r#" -/// Casts all elements of `self` to `i32`. - #[lua(kind = "Method", output(proxy))] - fn as_ivec4(&self) -> bevy::math::IVec4; + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" -/// Casts all elements of `self` to `u32`. - #[lua(kind = "Method", output(proxy))] - fn as_uvec4(&self) -> bevy::math::UVec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, rhs: f64) -> bevy::math::DVec4; "#, r#" -/// Casts all elements of `self` to `i64`. - #[lua(kind = "Method", output(proxy))] - fn as_i64vec4(&self) -> bevy::math::I64Vec4; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; "#, r#" -/// Casts all elements of `self` to `u64`. - #[lua(kind = "Method", output(proxy))] - fn as_u64vec4(&self) -> bevy::math::U64Vec4; + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" #[lua( - as_trait = "std::ops::Rem", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "rem", - metamethod = "Mod", + composite = "div", + metamethod = "Div", )] - fn rem(self, rhs: f64) -> bevy::math::DVec4; + fn div(self, #[proxy] rhs: &glam::DVec4) -> bevy::math::DVec4; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -14120,35 +16057,37 @@ struct DVec4 { functions[r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Mat2; + fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn div(self, rhs: f32) -> bevy::math::Mat2; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Add", + kind = "MetaFunction", output(proxy), + composite = "add", + metamethod = "Add", )] - fn clone(&self) -> bevy::math::Mat2; + fn add(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" @@ -14160,18 +16099,17 @@ struct DVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec2) -> bevy::math::Vec2; + fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + fn clone(&self) -> bevy::math::Mat2; "#, r#" @@ -14183,43 +16121,31 @@ struct DVec4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; + fn mul(self, rhs: f32) -> bevy::math::Mat2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, rhs: f32) -> bevy::math::Mat2; + fn neg(self) -> bevy::math::Mat2; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f32) -> bevy::math::Mat2; + fn sub(self, #[proxy] rhs: bevy::math::Mat2) -> bevy::math::Mat2; "#, r#" @@ -14282,6 +16208,21 @@ struct DVec4 { #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] m: bevy::math::Mat3) -> bevy::math::Mat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3_minor( + #[proxy] + m: bevy::math::Mat3, + i: usize, + j: usize, + ) -> bevy::math::Mat2; + "#, r#" /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. @@ -14289,6 +16230,21 @@ struct DVec4 { #[lua(kind = "Function", output(proxy))] fn from_mat3a(#[proxy] m: bevy::math::Mat3A) -> bevy::math::Mat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3a_minor( + #[proxy] + m: bevy::math::Mat3A, + i: usize, + j: usize, + ) -> bevy::math::Mat2; + "#, r#" /// Returns the matrix column for the given `index`. @@ -14414,11 +16370,22 @@ struct DVec4 { #[lua(kind = "Method", output(proxy))] fn as_dmat2(&self) -> bevy::math::DMat2; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Mat2) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -14452,18 +16419,6 @@ struct Mat2(); derive(clone), remote = "bevy::math::Mat3", functions[r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; - -"#, - r#" /// Creates a 3x3 matrix from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -14506,6 +16461,21 @@ struct Mat2(); #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::Mat4, + i: usize, + j: usize, + ) -> bevy::math::Mat3; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -14539,6 +16509,17 @@ struct Mat2(); c: f32, ) -> bevy::math::Mat3; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -14773,13 +16754,25 @@ struct Mat2(); r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn neg(self) -> bevy::math::Mat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Mat3; "#, r#" @@ -14791,19 +16784,19 @@ struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "mul", + metamethod = "Mul", )] - fn div(self, rhs: f32) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -14815,7 +16808,7 @@ struct Mat2(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" @@ -14831,37 +16824,36 @@ struct Mat2(); r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "sub", + metamethod = "Sub", )] - fn neg(self) -> bevy::math::Mat3; + fn sub(self, #[proxy] rhs: bevy::math::Mat3) -> bevy::math::Mat3; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; "#, r#" @@ -14879,18 +16871,19 @@ struct Mat2(); r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Mat3) -> bool; + fn mul(self, rhs: f32) -> bevy::math::Mat3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -14933,25 +16926,23 @@ struct Mat3 { functions[r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn clone(&self) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "add", + metamethod = "Add", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; + fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" @@ -14997,6 +16988,21 @@ struct Mat3 { #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::Mat4) -> bevy::math::Mat3A; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::Mat4, + i: usize, + j: usize, + ) -> bevy::math::Mat3A; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -15030,6 +17036,17 @@ struct Mat3 { c: f32, ) -> bevy::math::Mat3A; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -15264,58 +17281,61 @@ struct Mat3 { r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; + fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn div(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f32) -> bevy::math::Mat3A; + fn sub(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; + fn neg(self) -> bevy::math::Mat3A; "#, r#" @@ -15327,49 +17347,48 @@ struct Mat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + fn eq(&self, #[proxy] rhs: &glam::Mat3A) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "mul", + metamethod = "Mul", )] - fn add(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn mul(self, rhs: f32) -> bevy::math::Mat3A; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -15412,13 +17431,13 @@ struct Mat3A { functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "neg", + metamethod = "Unm", )] - fn div(self, rhs: f32) -> bevy::math::Mat4; + fn neg(self) -> bevy::math::Mat4; "#, r#" @@ -15442,28 +17461,7 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Mat4; + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; "#, r#" @@ -15475,31 +17473,17 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f32) -> bevy::math::Mat4; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "std::ops::Neg", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "neg", - metamethod = "Unm", )] - fn neg(self) -> bevy::math::Mat4; + fn clone(&self) -> bevy::math::Mat4; "#, r#" @@ -15511,19 +17495,18 @@ struct Mat3A { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Mat4; + fn mul(self, rhs: f32) -> bevy::math::Mat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + fn eq(&self, #[proxy] rhs: &glam::Mat4) -> bool; "#, r#" @@ -15667,6 +17650,18 @@ struct Mat3A { c: f32, ) -> bevy::math::Mat4; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f32, f32, f32); + "#, r#" /// Creates an affine transformation matrix containing a 3D rotation around the x axis of @@ -15835,7 +17830,8 @@ struct Mat3A { "#, r#" -/// Creates a right-handed perspective projection matrix with [-1,1] depth range. +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. /// This is the same as the OpenGL `gluPerspective` function. /// See @@ -15850,6 +17846,7 @@ struct Mat3A { "#, r#" /// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -15865,6 +17862,7 @@ struct Mat3A { "#, r#" /// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -15880,8 +17878,11 @@ struct Mat3A { "#, r#" /// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. /// # Panics -/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_lh( @@ -15892,7 +17893,8 @@ struct Mat3A { "#, r#" -/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. @@ -15905,8 +17907,12 @@ struct Mat3A { "#, r#" -/// Creates an infinite right-handed perspective projection matrix with -/// `[0,1]` depth range. +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_rh( @@ -15917,8 +17923,10 @@ struct Mat3A { "#, r#" -/// Creates an infinite reverse right-handed perspective projection matrix -/// with `[0,1]` depth range. +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_reverse_rh( @@ -15933,6 +17941,7 @@ struct Mat3A { /// range. This is the same as the OpenGL `glOrtho` function in OpenGL. /// See /// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. #[lua(kind = "Function", output(proxy))] fn orthographic_rh_gl( @@ -15947,6 +17956,7 @@ struct Mat3A { "#, r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_lh( @@ -15961,6 +17971,7 @@ struct Mat3A { "#, r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_rh( @@ -16008,6 +18019,16 @@ struct Mat3A { #[lua(kind = "Method", output(proxy))] fn transform_vector3(&self, #[proxy] rhs: bevy::math::Vec3) -> bevy::math::Vec3; +"#, + r#" +/// Transforms the given [`Vec3A`] as a 3D point, applying perspective correction. +/// This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. +/// The perspective divide is performed meaning the resulting 3D vector is divided by `w`. +/// This method assumes that `self` contains a projective transform. + + #[lua(kind = "Method", output(proxy))] + fn project_point3a(&self, #[proxy] rhs: bevy::math::Vec3A) -> bevy::math::Vec3A; + "#, r#" /// Transforms the given [`Vec3A`] as 3D point. @@ -16092,11 +18113,47 @@ struct Mat3A { #[lua(kind = "Method", output(proxy))] fn as_dmat4(&self) -> bevy::math::DMat4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Vec4) -> bevy::math::Vec4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Div", + kind = "MetaFunction", + output(proxy), + composite = "div", + metamethod = "Div", + )] + fn div(self, rhs: f32) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -16132,33 +18189,22 @@ struct Mat4 { #[lua(output(proxy))] z_axis: bevy::math::Vec4, #[lua(output(proxy))] - w_axis: bevy::math::Vec4, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DMat2", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; - -"#, - r#" + w_axis: bevy::math::Vec4, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DMat2", + functions[r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "sub", + metamethod = "Sub", )] - fn div(self, rhs: f64) -> bevy::math::DMat2; + fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; "#, r#" @@ -16172,18 +18218,6 @@ struct Mat4 { )] fn neg(self) -> bevy::math::DMat2; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - "#, r#" @@ -16200,37 +18234,24 @@ struct Mat4 { r#" #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "div", + metamethod = "Div", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + fn div(self, rhs: f64) -> bevy::math::DMat2; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + fn eq(&self, #[proxy] rhs: &glam::DMat2) -> bool; "#, r#" @@ -16303,6 +18324,21 @@ struct Mat4 { #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] m: bevy::math::DMat3) -> bevy::math::DMat2; +"#, + r#" +/// Creates a 2x2 matrix from the minor of the given 3x3 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 2. + + #[lua(kind = "Function", output(proxy))] + fn from_mat3_minor( + #[proxy] + m: bevy::math::DMat3, + i: usize, + j: usize, + ) -> bevy::math::DMat2; + "#, r#" /// Returns the matrix column for the given `index`. @@ -16428,11 +18464,47 @@ struct Mat4 { #[lua(kind = "Method", output(proxy))] fn as_mat2(&self) -> bevy::math::Mat2; +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DVec2) -> bevy::math::DVec2; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", + kind = "MetaFunction", + output(proxy), + composite = "add", + metamethod = "Add", + )] + fn add(self, #[proxy] rhs: bevy::math::DMat2) -> bevy::math::DMat2; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -16473,71 +18545,106 @@ struct DMat2 { functions[r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::DMat3; + fn mul(self, rhs: f64) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "std::ops::Add", + as_trait = "std::ops::Div", kind = "MetaFunction", output(proxy), - composite = "add", - metamethod = "Add", + composite = "div", + metamethod = "Div", )] - fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn div(self, rhs: f64) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::DMat3; + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "std::ops::Div", + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "div", - metamethod = "Div", + composite = "add", + metamethod = "Add", )] - fn div(self, rhs: f64) -> bevy::math::DMat3; + fn add(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Sub", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "sub", + metamethod = "Sub", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; + fn sub(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DMat3; "#, r#" @@ -16583,6 +18690,21 @@ struct DMat2 { #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] m: bevy::math::DMat4) -> bevy::math::DMat3; +"#, + r#" +/// Creates a 3x3 matrix from the minor of the given 4x4 matrix, discarding the `i`th column +/// and `j`th row. +/// # Panics +/// Panics if `i` or `j` is greater than 3. + + #[lua(kind = "Function", output(proxy))] + fn from_mat4_minor( + #[proxy] + m: bevy::math::DMat4, + i: usize, + j: usize, + ) -> bevy::math::DMat3; + "#, r#" /// Creates a 3D rotation matrix from the given quaternion. @@ -16620,6 +18742,17 @@ struct DMat2 { c: f64, ) -> bevy::math::DMat3; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the input matrix contains scales, shears, or other non-rotation transformations then +/// the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); + "#, r#" /// Creates a 3D rotation matrix from `angle` (in radians) around the x axis. @@ -16853,48 +18986,13 @@ struct DMat2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat3) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat3; + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DMat3; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -16936,71 +19034,49 @@ struct DMat3 { remote = "bevy::math::DMat4", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; - -"#, - r#" - #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), composite = "mul", - metamethod = "Mul", - )] - fn mul(self, rhs: f64) -> bevy::math::DMat4; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Sub", + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "sub", - metamethod = "Sub", + composite = "mul", + metamethod = "Mul", )] - fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn mul(self, rhs: f64) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn eq(&self, #[proxy] rhs: &glam::DMat4) -> bool; "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::ops::Neg", kind = "MetaFunction", output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "neg", + metamethod = "Unm", )] - fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; + fn neg(self) -> bevy::math::DMat4; "#, r#" @@ -17024,7 +19100,7 @@ struct DMat3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DVec4) -> bevy::math::DVec4; "#, r#" @@ -17162,6 +19238,18 @@ struct DMat3 { c: f64, ) -> bevy::math::DMat4; +"#, + r#" +/// Extract Euler angles with the given Euler rotation order. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting Euler angles will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. + + #[lua(kind = "Method")] + fn to_euler(&self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); + "#, r#" /// Creates an affine transformation matrix containing a 3D rotation around the x axis of @@ -17330,7 +19418,8 @@ struct DMat3 { "#, r#" -/// Creates a right-handed perspective projection matrix with [-1,1] depth range. +/// Creates a right-handed perspective projection matrix with `[-1,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what OpenGL expects. /// This is the same as the OpenGL `gluPerspective` function. /// See @@ -17345,6 +19434,7 @@ struct DMat3 { "#, r#" /// Creates a left-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard left-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -17360,6 +19450,7 @@ struct DMat3 { "#, r#" /// Creates a right-handed perspective projection matrix with `[0,1]` depth range. +/// Useful to map the standard right-handed coordinate system into what WebGPU/Metal/Direct3D expect. /// # Panics /// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is /// enabled. @@ -17375,8 +19466,11 @@ struct DMat3 { "#, r#" /// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_lh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. /// # Panics -/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_lh( @@ -17387,7 +19481,8 @@ struct DMat3 { "#, r#" -/// Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. +/// Creates an infinite reverse left-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_lh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. /// # Panics /// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. @@ -17400,8 +19495,12 @@ struct DMat3 { "#, r#" -/// Creates an infinite right-handed perspective projection matrix with -/// `[0,1]` depth range. +/// Creates an infinite right-handed perspective projection matrix with `[0,1]` depth range. +/// Like `perspective_rh`, but with an infinite value for `z_far`. +/// The result is that points near `z_near` are mapped to depth `0`, and as they move towards infinity the depth approaches `1`. +/// # Panics +/// Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is +/// enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_rh( @@ -17412,8 +19511,10 @@ struct DMat3 { "#, r#" -/// Creates an infinite reverse right-handed perspective projection matrix -/// with `[0,1]` depth range. +/// Creates an infinite reverse right-handed perspective projection matrix with `[0,1]` depth range. +/// Similar to `perspective_infinite_rh`, but maps `Z = z_near` to a depth of `1` and `Z = infinity` to a depth of `0`. +/// # Panics +/// Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn perspective_infinite_reverse_rh( @@ -17428,6 +19529,7 @@ struct DMat3 { /// range. This is the same as the OpenGL `glOrtho` function in OpenGL. /// See /// +/// Useful to map a right-handed coordinate system to the normalized device coordinates that OpenGL expects. #[lua(kind = "Function", output(proxy))] fn orthographic_rh_gl( @@ -17442,6 +19544,7 @@ struct DMat3 { "#, r#" /// Creates a left-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a left-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_lh( @@ -17456,6 +19559,7 @@ struct DMat3 { "#, r#" /// Creates a right-handed orthographic projection matrix with `[0,1]` depth range. +/// Useful to map a right-handed coordinate system to the normalized device coordinates that WebGPU/Direct3D/Metal expect. #[lua(kind = "Function", output(proxy))] fn orthographic_rh( @@ -17575,13 +19679,23 @@ struct DMat3 { r#" #[lua( - as_trait = "std::ops::Neg", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::DMat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "mul", + metamethod = "Mul", )] - fn neg(self) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DMat4; "#, r#" @@ -17595,11 +19709,23 @@ struct DMat3 { )] fn div(self, rhs: f64) -> bevy::math::DMat4; +"#, + r#" + + #[lua( + as_trait = "std::ops::Sub", + kind = "MetaFunction", + output(proxy), + composite = "sub", + metamethod = "Sub", + )] + fn sub(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#, r#" @@ -17642,29 +19768,6 @@ struct DMat4 { derive(clone), remote = "bevy::math::Affine2", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; - -"#, - r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -17837,11 +19940,13 @@ struct DMat4 { r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::Affine2; + fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; "#, r#" @@ -17865,13 +19970,34 @@ struct DMat4 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat3A) -> bevy::math::Mat3A; + fn mul(self, #[proxy] rhs: bevy::math::Affine2) -> bevy::math::Affine2; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine2) -> bool; + +"#, + r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine2; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -17886,6 +20012,51 @@ struct Affine2 { derive(clone), remote = "bevy::math::Affine3A", functions[r#" + + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> bevy::math::Affine3A; + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; + +"#, + r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -18173,14 +20344,30 @@ struct Affine2 { "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct Affine3A { + #[lua(output(proxy))] + matrix3: bevy::math::Mat3A, + #[lua(output(proxy))] + translation: bevy::math::Vec3A, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DAffine2", + functions[r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::Affine3A) -> bool; + fn clone(&self) -> bevy::math::DAffine2; "#, r#" @@ -18192,7 +20379,7 @@ struct Affine2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Mat4) -> bevy::math::Mat4; + fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; "#, r#" @@ -18204,46 +20391,18 @@ struct Affine2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::Affine3A) -> bevy::math::Affine3A; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::Affine3A; + fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct Affine3A { - #[lua(output(proxy))] - matrix3: bevy::math::Mat3A, - #[lua(output(proxy))] - translation: bevy::math::Vec3A, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine2", - functions[r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat3) -> bevy::math::DMat3; + fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; "#, r#" @@ -18405,8 +20564,37 @@ struct Affine3A { /// Return the inverse of this transform. /// Note that if the transform is not invertible the result will be invalid. - #[lua(kind = "Method", output(proxy))] - fn inverse(&self) -> bevy::math::DAffine2; + #[lua(kind = "Method", output(proxy))] + fn inverse(&self) -> bevy::math::DAffine2; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct DAffine2 { + #[lua(output(proxy))] + matrix2: bevy::math::DMat2, + #[lua(output(proxy))] + translation: bevy::math::DVec2, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DAffine3", + functions[r#" + + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; "#, r#" @@ -18417,49 +20605,32 @@ struct Affine3A { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] rhs: &glam::DAffine2) -> bool; + fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; "#, r#" #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Mul", + kind = "MetaFunction", output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn clone(&self) -> bevy::math::DAffine2; + fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; "#, r#" #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", output(proxy), - composite = "mul", - metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine2) -> bevy::math::DAffine2; + fn clone(&self) -> bevy::math::DAffine3; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct DAffine2 { - #[lua(output(proxy))] - matrix2: bevy::math::DMat2, - #[lua(output(proxy))] - translation: bevy::math::DVec2, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DAffine3", - functions[r#" /// Creates an affine transform from three column vectors. #[lua(kind = "Function", output(proxy))] @@ -18731,27 +20902,53 @@ struct DAffine2 { "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct DAffine3 { + #[lua(output(proxy))] + matrix3: bevy::math::DMat3, + #[lua(output(proxy))] + translation: bevy::math::DVec3, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::math::DQuat", + functions[r#" +/// Divides a quaternion by a scalar value. +/// The quotient is not guaranteed to be normalized. #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Div", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "div", + metamethod = "Div", )] - fn eq(&self, #[proxy] rhs: &glam::DAffine3) -> bool; + fn div(self, rhs: f64) -> bevy::math::DQuat; "#, r#" +/// Subtracts the `rhs` quaternion from `self`. +/// The difference is not guaranteed to be normalized. #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", + as_trait = "std::ops::Sub", + kind = "MetaFunction", output(proxy), + composite = "sub", + metamethod = "Sub", )] - fn clone(&self) -> bevy::math::DAffine3; + fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" +/// Multiplies a quaternion by a scalar value. +/// The product is not guaranteed to be normalized. #[lua( as_trait = "std::ops::Mul", @@ -18760,10 +20957,28 @@ struct DAffine2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DAffine3) -> bevy::math::DAffine3; + fn mul(self, rhs: f64) -> bevy::math::DQuat; + +"#, + r#" + + #[lua( + as_trait = "std::ops::Neg", + kind = "MetaFunction", + output(proxy), + composite = "neg", + metamethod = "Unm", + )] + fn neg(self) -> bevy::math::DQuat; "#, r#" +/// 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", @@ -18772,41 +20987,29 @@ struct DAffine2 { composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] rhs: bevy::math::DMat4) -> bevy::math::DMat4; + fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct DAffine3 { - #[lua(output(proxy))] - matrix3: bevy::math::DMat3, - #[lua(output(proxy))] - translation: bevy::math::DVec3, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::math::DQuat", - functions[r#" +/// Adds two quaternions. +/// The sum is not guaranteed to be normalized. +/// Note that addition is not the same as combining the rotations represented by the +/// two quaternions! That corresponds to multiplication. #[lua( - as_trait = "std::ops::Neg", + as_trait = "std::ops::Add", kind = "MetaFunction", output(proxy), - composite = "neg", - metamethod = "Unm", + composite = "add", + metamethod = "Add", )] - fn neg(self) -> bevy::math::DQuat; + fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; "#, r#" -/// Multiplies a quaternion by a scalar value. -/// The product is not guaranteed to be normalized. +/// Multiplies a quaternion and a 3D vector, returning the rotated vector. +/// # Panics +/// Will panic if `self` is not normalized when `glam_assert` is enabled. #[lua( as_trait = "std::ops::Mul", @@ -18815,32 +21018,28 @@ struct DAffine3 { composite = "mul", metamethod = "Mul", )] - fn mul(self, rhs: f64) -> bevy::math::DQuat; + fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; + fn clone(&self) -> bevy::math::DQuat; "#, r#" -/// Divides a quaternion by a scalar value. -/// The quotient is not guaranteed to be normalized. #[lua( - as_trait = "std::ops::Div", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "div", - metamethod = "Div", + composite = "eq", + metamethod = "Eq", )] - fn div(self, rhs: f64) -> bevy::math::DQuat; + fn eq(&self, #[proxy] rhs: &glam::DQuat) -> bool; "#, r#" @@ -18934,13 +21133,22 @@ struct DAffine3 { "#, r#" /// Creates a quaternion from a 3x3 rotation matrix. +/// Note if the input matrix contain scales, shears, or other non-rotation transformations then +/// the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input matrix column is not normalized when `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat3(#[proxy] mat: &glam::DMat3) -> bevy::math::DQuat; "#, r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Creates a quaternion from the upper 3x3 rotation matrix inside a homogeneous 4x4 matrix. +/// Note if the upper 3x3 matrix contain scales, shears, or other non-rotation transformations +/// then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any column of the upper 3x3 rotation matrix is not normalized when +/// `glam_assert` is enabled. #[lua(kind = "Function", output(proxy))] fn from_mat4(#[proxy] mat: &glam::DMat4) -> bevy::math::DQuat; @@ -19014,7 +21222,7 @@ struct DAffine3 { /// Returns the rotation angles for the given euler rotation sequence. #[lua(kind = "Method")] - fn to_euler(self, #[proxy] euler: bevy::math::EulerRot) -> (f64, f64, f64); + fn to_euler(self, #[proxy] order: bevy::math::EulerRot) -> (f64, f64, f64); "#, r#" @@ -19102,6 +21310,7 @@ struct DAffine3 { "#, r#" +/// Returns `true` if any elements are `NAN`. #[lua(kind = "Method")] fn is_nan(self) -> bool; @@ -19131,6 +21340,24 @@ struct DAffine3 { #[lua(kind = "Method")] fn angle_between(self, #[proxy] rhs: bevy::math::DQuat) -> f64; +"#, + r#" +/// Rotates towards `rhs` up to `max_angle` (in radians). +/// When `max_angle` is `0.0`, the result will be equal to `self`. When `max_angle` is equal to +/// `self.angle_between(rhs)`, the result will be equal to `rhs`. If `max_angle` is negative, +/// rotates towards the exact opposite of `rhs`. Will not go past the target. +/// Both quaternions must be normalized. +/// # Panics +/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn rotate_towards( + &self, + #[proxy] + rhs: bevy::math::DQuat, + max_angle: f64, + ) -> bevy::math::DQuat; + "#, r#" /// Returns true if the absolute difference of all elements between `self` and `rhs` @@ -19161,81 +21388,12 @@ struct DAffine3 { /// Performs a spherical linear interpolation between `self` and `end` /// based on the value `s`. /// When `s` is `0.0`, the result will be equal to `self`. When `s` -/// is `1.0`, the result will be equal to `end`. -/// # Panics -/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; - -"#, - r#" -/// Multiplies a quaternion and a 3D vector, returning the rotated vector. -/// # Panics -/// Will panic if `self` is not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; - -"#, - r#" -/// Multiplies two quaternions. If they each represent a rotation, the result will -/// represent the combined rotation. -/// Note that due to floating point rounding the result may not be perfectly normalized. -/// # Panics -/// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - - #[lua(kind = "Method", output(proxy))] - fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - - #[lua(kind = "Function", output(proxy))] - fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_quat(self) -> bevy::math::Quat; - -"#, - r#" - - #[lua(kind = "Method", output(proxy))] - fn as_f32(self) -> bevy::math::Quat; - -"#, - r#" -/// Subtracts the `rhs` quaternion from `self`. -/// The difference is not guaranteed to be normalized. - - #[lua( - as_trait = "std::ops::Sub", - kind = "MetaFunction", - output(proxy), - composite = "sub", - metamethod = "Sub", - )] - fn sub(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; - -"#, - r#" -/// Adds two quaternions. -/// The sum is not guaranteed to be normalized. -/// Note that addition is not the same as combining the rotations represented by the -/// two quaternions! That corresponds to multiplication. - - #[lua( - as_trait = "std::ops::Add", - kind = "MetaFunction", - output(proxy), - composite = "add", - metamethod = "Add", - )] - fn add(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; +/// is `1.0`, the result will be equal to `end`. +/// # Panics +/// Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. + + #[lua(kind = "Method", output(proxy))] + fn slerp(self, #[proxy] end: bevy::math::DQuat, s: f64) -> bevy::math::DQuat; "#, r#" @@ -19243,48 +21401,43 @@ struct DAffine3 { /// # Panics /// Will panic if `self` is not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; + #[lua(kind = "Method", output(proxy))] + fn mul_vec3(self, #[proxy] rhs: bevy::math::DVec3) -> bevy::math::DVec3; "#, r#" /// Multiplies two quaternions. If they each represent a rotation, the result will /// represent the combined rotation. -/// Note that due to floating point rounding the result may not be perfectly -/// normalized. +/// Note that due to floating point rounding the result may not be perfectly normalized. /// # Panics /// Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + #[lua(kind = "Method", output(proxy))] + fn mul_quat(self, #[proxy] rhs: bevy::math::DQuat) -> bevy::math::DQuat; + +"#, + r#" +/// Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. +/// Note if the input affine matrix contain scales, shears, or other non-rotation +/// transformations then the resulting quaternion will be ill-defined. +/// # Panics +/// Will panic if any input affine matrix column is not normalized when `glam_assert` is +/// enabled. + + #[lua(kind = "Function", output(proxy))] + fn from_affine3(#[proxy] a: &glam::DAffine3) -> bevy::math::DQuat; "#, r#" - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> bevy::math::DQuat; + #[lua(kind = "Method", output(proxy))] + fn as_quat(self) -> bevy::math::Quat; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19338,17 +21491,6 @@ struct EulerRot {} derive(clone), remote = "bevy::math::BVec3A", functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; - -"#, - r#" /// Creates a new vector mask. #[lua(kind = "Function", output(proxy))] @@ -19407,6 +21549,17 @@ struct EulerRot {} #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec3A) -> bool; + "#, r#" @@ -19421,7 +21574,7 @@ struct EulerRot {} r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19432,6 +21585,17 @@ struct BVec3A(); remote = "bevy::math::BVec4A", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; + +"#, + r#" + #[lua( as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", kind = "Method", @@ -19499,285 +21663,110 @@ struct BVec3A(); #[lua(kind = "MutatingMethod")] fn set(&mut self, index: usize, value: bool) -> (); -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] rhs: &glam::BVec4A) -> bool; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] struct BVec4A(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "smol_str::SmolStr", - functions[r#" - - #[lua(kind = "Method")] - fn to_string(&self) -> std::string::String; - -"#, - r#" - - #[lua(kind = "Method")] - fn len(&self) -> usize; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_empty(&self) -> bool; - -"#, - r#" - - #[lua(kind = "Method")] - fn is_heap_allocated(&self) -> bool; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; - -"#, - r#" - - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> smol_str::SmolStr; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{}", _self) -} -"#] -)] -struct SmolStr(); -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "uuid::Uuid", - functions[r#" -/// Returns the version number of the UUID. -/// This represents the algorithm used to generate the value. -/// This method is the future-proof alternative to [`Uuid::get_version`]. -/// # 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(kind = "Method")] - fn get_version_num(&self) -> 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(kind = "Method")] - fn as_u128(&self) -> 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(kind = "Method")] - fn to_u128_le(&self) -> 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(kind = "Method")] - fn as_u64_pair(&self) -> (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()); -/// ``` +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "smol_str::SmolStr", + functions[r#" - #[lua(kind = "Method")] - fn into_bytes(self) -> [u8; 16]; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &smol_str::SmolStr) -> bool; "#, 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(kind = "Method")] - fn to_bytes_le(&self) -> [u8; 16]; + #[lua( + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), + )] + fn clone(&self) -> smol_str::SmolStr; "#, r#" -/// Tests if the UUID is nil (all zeros). #[lua(kind = "Method")] - fn is_nil(&self) -> bool; + fn to_string(&self) -> std::string::String; "#, r#" -/// Tests if the UUID is max (all ones). #[lua(kind = "Method")] - fn is_max(&self) -> bool; + fn len(&self) -> usize; "#, 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(kind = "Function")] - fn encode_buffer() -> [u8; 45]; + #[lua(kind = "Method")] + fn is_empty(&self) -> bool; "#, r#" -/// If the UUID is the correct version (v1, or v6) this will return the -/// node value as a 6-byte array. For other versions this will return `None`. #[lua(kind = "Method")] - fn get_node_id( - &self, - ) -> bevy::reflect::erased_serde::__private::serde::__private::Option<[u8; 6]>; + fn is_heap_allocated(&self) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct SmolStr(); +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "uuid::Uuid", + functions[r#" +/// 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(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(kind = "Function", output(proxy))] + fn new_v4() -> uuid::Uuid; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", + kind = "Method", + output(proxy), )] - fn eq(&self, #[proxy] other: &uuid::Uuid) -> bool; + fn clone(&self) -> uuid::Uuid; "#, r#" @@ -19836,57 +21825,197 @@ struct SmolStr(); /// ); /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u128(v: u128) -> uuid::Uuid; + #[lua(kind = "Function", output(proxy))] + fn from_u128(v: u128) -> uuid::Uuid; + +"#, + 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(kind = "Function", output(proxy))] + fn from_u128_le(v: u128) -> uuid::Uuid; + +"#, + 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(kind = "Function", output(proxy))] + fn from_u64_pair(high_bits: u64, low_bits: u64) -> uuid::Uuid; + +"#, + 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(kind = "Function", output(proxy))] + fn from_bytes(bytes: [u8; 16]) -> uuid::Uuid; + +"#, + 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(kind = "Function", output(proxy))] + fn from_bytes_le(b: [u8; 16]) -> uuid::Uuid; + +"#, + 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(kind = "Method")] + fn get_version_num(&self) -> 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(kind = "Method")] + fn as_u128(&self) -> u128; "#, r#" -/// Creates a UUID from a 128bit value in little-endian order. -/// The entire value will be flipped to convert into big-endian order. -/// This is based on the endianness of the UUID, rather than the target -/// environment so bytes will be flipped on both big and little endian -/// machines. +/// Returns a 128bit little-endian value containing the value. +/// The bytes in the `u128` will be flipped to convert into big-endian +/// order. This is based on the endianness of the UUID, rather than the +/// target environment so bytes will be flipped on both big and little +/// endian machines. +/// Note that this will produce a different result than +/// [`Uuid::to_fields_le`], because the entire UUID is reversed, rather +/// than reversing the individual fields in-place. /// # Examples -/// Basic usage: /// ``` /// # use uuid::Uuid; -/// let v = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8u128; -/// let uuid = Uuid::from_u128_le(v); +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "d8d7d6d5-d4d3-d2d1-c2c1-b2b1a4a3a2a1", -/// uuid.hyphenated().to_string(), +/// uuid.to_u128_le(), +/// 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1, /// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u128_le(v: u128) -> uuid::Uuid; + #[lua(kind = "Method")] + fn to_u128_le(&self) -> u128; "#, r#" -/// Creates a UUID from two 64bit values. +/// Returns two 64bit values containing the value. +/// The bytes in the UUID will be split into two `u64`. +/// The first u64 represents the 64 most significant bits, +/// the second one represents the 64 least significant. /// # Examples -/// Basic usage: /// ``` /// # use uuid::Uuid; -/// let hi = 0xa1a2a3a4b1b2c1c2u64; -/// let lo = 0xd1d2d3d4d5d6d7d8u64; -/// let uuid = Uuid::from_u64_pair(hi, lo); +/// # fn main() -> Result<(), uuid::Error> { +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), +/// uuid.as_u64_pair(), +/// (0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8), /// ); +/// # Ok(()) +/// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_u64_pair(high_bits: u64, low_bits: u64) -> uuid::Uuid; + #[lua(kind = "Method")] + fn as_u64_pair(&self) -> (u64, u64); "#, r#" -/// Creates a UUID using the supplied bytes. +/// Consumes self and returns the underlying byte value of the UUID. /// # Examples -/// Basic usage: /// ``` -/// # fn main() -> Result<(), uuid::Error> { /// # use uuid::Uuid; /// let bytes = [ /// 0xa1, 0xa2, 0xa3, 0xa4, @@ -19895,85 +22024,109 @@ struct SmolStr(); /// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, /// ]; /// let uuid = Uuid::from_bytes(bytes); -/// assert_eq!( -/// uuid.hyphenated().to_string(), -/// "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8" -/// ); -/// # Ok(()) -/// # } +/// assert_eq!(bytes, uuid.into_bytes()); /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_bytes(bytes: [u8; 16]) -> uuid::Uuid; + #[lua(kind = "Method")] + fn into_bytes(self) -> [u8; 16]; "#, r#" -/// Creates a UUID using the supplied bytes in little endian order. -/// The individual fields encoded in the buffer will be flipped. +/// Returns the bytes of the UUID in little-endian order. +/// The bytes will be flipped to convert into little-endian order. This is +/// based on the endianness of the UUID, rather than the target environment +/// so bytes will be flipped on both big and little endian machines. /// # Examples -/// Basic usage: /// ``` +/// use uuid::Uuid; /// # fn main() -> Result<(), uuid::Error> { -/// # use uuid::Uuid; -/// let bytes = [ -/// 0xa1, 0xa2, 0xa3, 0xa4, -/// 0xb1, 0xb2, -/// 0xc1, 0xc2, -/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, -/// ]; -/// let uuid = Uuid::from_bytes_le(bytes); +/// let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?; /// assert_eq!( -/// "a4a3a2a1-b2b1-c2c1-d1d2-d3d4d5d6d7d8", -/// uuid.hyphenated().to_string(), +/// uuid.to_bytes_le(), +/// ([ +/// 0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2, +/// 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 +/// ]) /// ); /// # Ok(()) /// # } /// ``` - #[lua(kind = "Function", output(proxy))] - fn from_bytes_le(b: [u8; 16]) -> uuid::Uuid; + #[lua(kind = "Method")] + fn to_bytes_le(&self) -> [u8; 16]; "#, r#" +/// Tests if the UUID is nil (all zeros). - #[lua( - as_trait = "bevy::reflect::erased_serde::__private::serde::__private::Clone", - kind = "Method", - output(proxy), - )] - fn clone(&self) -> uuid::Uuid; + #[lua(kind = "Method")] + fn is_nil(&self) -> bool; "#, r#" -/// Creates a random UUID. -/// This uses the [`getrandom`] crate to utilise the operating system's RNG -/// as the source of random numbers. If you'd like to use a custom -/// generator, don't use this method: generate random bytes using your -/// custom generator and pass them to the -/// [`uuid::Builder::from_random_bytes`][from_random_bytes] function -/// instead. -/// Note that usage of this method requires the `v4` feature of this crate -/// to be enabled. +/// Tests if the UUID is max (all ones). + + #[lua(kind = "Method")] + fn is_max(&self) -> bool; + +"#, + r#" +/// A buffer that can be used for `encode_...` calls, that is +/// guaranteed to be long enough for any of the format adapters. /// # Examples -/// Basic usage: /// ``` -/// # use uuid::{Uuid, Version}; -/// let uuid = Uuid::new_v4(); -/// assert_eq!(Some(Version::Random), uuid.get_version()); +/// # use uuid::Uuid; +/// let uuid = Uuid::nil(); +/// assert_eq!( +/// uuid.simple().encode_lower(&mut Uuid::encode_buffer()), +/// "00000000000000000000000000000000" +/// ); +/// assert_eq!( +/// uuid.hyphenated() +/// .encode_lower(&mut Uuid::encode_buffer()), +/// "00000000-0000-0000-0000-000000000000" +/// ); +/// assert_eq!( +/// uuid.urn().encode_lower(&mut Uuid::encode_buffer()), +/// "urn:uuid:00000000-0000-0000-0000-000000000000" +/// ); /// ``` -/// # References -/// * [UUID Version 4 in RFC 9562](https://www.ietf.org/rfc/rfc9562.html#section-5.4) -/// [`getrandom`]: https://crates.io/crates/getrandom -/// [from_random_bytes]: struct.Builder.html#method.from_random_bytes - #[lua(kind = "Function", output(proxy))] - fn new_v4() -> uuid::Uuid; + #[lua(kind = "Function")] + fn encode_buffer() -> [u8; 45]; + +"#, + r#" +/// If the UUID is the correct version (v1, or v6) this will return the +/// node value as a 6-byte array. For other versions this will return `None`. + + #[lua(kind = "Method")] + fn get_node_id( + &self, + ) -> bevy::reflect::erased_serde::__private::serde::__private::Option<[u8; 6]>; + +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &uuid::Uuid) -> bool; "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { - format!("{}", _self) + format!("{:?}", _self) } "#] )] @@ -19985,6 +22138,61 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals { 'lua, T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>, >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { + instances + .add_instance( + "AtomicBool", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicI8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicIsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU16", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU32", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU64", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicU8", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; + instances + .add_instance( + "AtomicUsize", + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, + )?; instances .add_instance( "Duration", @@ -20215,6 +22423,72 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { |tw| { tw.document_global_instance::() .expect("Something went wrong documenting globals") + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicBool, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicI8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicIsize, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU16, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU32, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU64, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicU8, + >, + >() + .process_type::() + .process_type::< + bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< + LuaAtomicUsize, + >, + >() .process_type::() .process_type::< bevy_mod_scripting_lua::tealr::mlu::UserDataProxy< @@ -20410,6 +22684,17 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyReflectAPIProvider { Ok(()) } fn register_with_app(&self, app: &mut bevy::app::App) { + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/bevy_time.rs b/crates/bevy_script_api/src/providers/bevy_time.rs index 377313b2..5f5629cd 100644 --- a/crates/bevy_script_api/src/providers/bevy_time.rs +++ b/crates/bevy_script_api/src/providers/bevy_time.rs @@ -149,6 +149,14 @@ struct Real {} #[lua(kind = "Method")] fn elapsed_secs(&self) -> f32; +"#, + r#" +/// Returns the time elapsed on the timer as an `f64`. +/// See also [`Timer::elapsed`](Timer::elapsed). + + #[lua(kind = "Method")] + fn elapsed_secs_f64(&self) -> f64; + "#, r#" /// Sets the elapsed time of the timer without any other considerations. @@ -262,7 +270,7 @@ struct Real {} "#, r#" /// Returns `true` if the timer is paused. -/// See also [`Stopwatch::paused`](Stopwatch::paused). +/// See also [`Stopwatch::is_paused`](Stopwatch::is_paused). /// # Examples /// ``` /// # use bevy_time::*; @@ -380,6 +388,12 @@ struct Real {} #[lua(kind = "Method")] fn times_finished_this_tick(&self) -> u32; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -391,12 +405,6 @@ struct Real {} )] fn eq(&self, #[proxy] other: &timer::Timer) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -412,12 +420,6 @@ struct Timer {} remote = "bevy::time::prelude::TimerMode", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -426,6 +428,12 @@ struct Timer {} )] fn eq(&self, #[proxy] other: &timer::TimerMode) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -465,12 +473,6 @@ struct Virtual {} remote = "bevy::time::Stopwatch", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -479,6 +481,12 @@ struct Virtual {} )] fn eq(&self, #[proxy] other: &stopwatch::Stopwatch) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::time::Stopwatch; + "#, r#" /// Create a new unpaused `Stopwatch` with no elapsed time. @@ -487,7 +495,7 @@ struct Virtual {} /// # use bevy_time::*; /// let stopwatch = Stopwatch::new(); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); -/// assert_eq!(stopwatch.paused(), false); +/// assert_eq!(stopwatch.is_paused(), false); /// ``` #[lua(kind = "Function", output(proxy))] @@ -568,7 +576,7 @@ struct Virtual {} /// let mut stopwatch = Stopwatch::new(); /// stopwatch.pause(); /// stopwatch.tick(Duration::from_secs_f32(1.5)); -/// assert!(stopwatch.paused()); +/// assert!(stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` @@ -587,7 +595,7 @@ struct Virtual {} /// stopwatch.tick(Duration::from_secs_f32(1.0)); /// stopwatch.unpause(); /// stopwatch.tick(Duration::from_secs_f32(1.0)); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// ``` @@ -601,15 +609,15 @@ struct Virtual {} /// ``` /// # use bevy_time::*; /// let mut stopwatch = Stopwatch::new(); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// stopwatch.pause(); -/// assert!(stopwatch.paused()); +/// assert!(stopwatch.is_paused()); /// stopwatch.unpause(); -/// assert!(!stopwatch.paused()); +/// assert!(!stopwatch.is_paused()); /// ``` #[lua(kind = "Method")] - fn paused(&self) -> bool; + fn is_paused(&self) -> bool; "#, r#" @@ -630,8 +638,8 @@ struct Virtual {} "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::time::Stopwatch; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" diff --git a/crates/bevy_script_api/src/providers/bevy_transform.rs b/crates/bevy_script_api/src/providers/bevy_transform.rs index 0a55f0c6..bb78e6d3 100644 --- a/crates/bevy_script_api/src/providers/bevy_transform.rs +++ b/crates/bevy_script_api/src/providers/bevy_transform.rs @@ -5,8 +5,8 @@ use super::bevy_ecs::*; use super::bevy_reflect::*; use super::bevy_core::*; -use super::bevy_hierarchy::*; use super::bevy_math::*; +use super::bevy_hierarchy::*; extern crate self as bevy_script_api; use bevy_script_api::{ lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld, @@ -17,19 +17,30 @@ use bevy_script_api::{ remote = "bevy::transform::components::GlobalTransform", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::GlobalTransform; + #[lua( + as_trait = "std::ops::Mul", + kind = "MetaFunction", + output(proxy), + composite = "mul", + metamethod = "Mul", + )] + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" #[lua( - as_trait = "std::cmp::PartialEq", + as_trait = "std::ops::Mul", kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", + output(proxy), + composite = "mul", + metamethod = "Mul", )] - fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; + fn mul( + self, + #[proxy] + global_transform: bevy::transform::components::GlobalTransform, + ) -> bevy::transform::components::GlobalTransform; "#, r#" @@ -64,6 +75,15 @@ use bevy_script_api::{ scale: bevy::math::Vec3, ) -> bevy::transform::components::GlobalTransform; +"#, + r#" + + #[lua(kind = "Function", output(proxy))] + fn from_isometry( + #[proxy] + iso: bevy::math::Isometry3d, + ) -> bevy::transform::components::GlobalTransform; + "#, r#" /// Returns the 3d affine transformation matrix as a [`Mat4`]. @@ -87,6 +107,17 @@ use bevy_script_api::{ #[lua(kind = "Method", output(proxy))] fn compute_transform(&self) -> bevy::transform::components::Transform; +"#, + r#" +/// Returns the isometric part of the transformation as an [isometry]. Any scaling done by the +/// transformation will be ignored. +/// The transform is expected to be non-degenerate and without shearing, or the output +/// will be invalid. +/// [isometry]: Isometry3d + + #[lua(kind = "Method", output(proxy))] + fn to_isometry(&self) -> bevy::math::Isometry3d; + "#, r#" /// Returns the [`Transform`] `self` would have if it was a child of an entity @@ -192,8 +223,35 @@ use bevy_script_api::{ "#, r#" -/// Transforms the given `point`, applying shear, scale, rotation and translation. -/// This moves `point` into the local space of this [`GlobalTransform`]. +/// Transforms the given point from local space to global space, applying shear, scale, rotation and translation. +/// It can be used like this: +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::prelude::Vec3; +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_point = Vec3::new(1., 2., 3.); +/// let global_point = global_transform.transform_point(local_point); +/// assert_eq!(global_point, Vec3::new(2., 4., 6.)); +/// ``` +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::Vec3; +/// let global_point = Vec3::new(2., 4., 6.); +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_point = global_transform.affine().inverse().transform_point3(global_point); +/// assert_eq!(local_point, Vec3::new(1., 2., 3.)) +/// ``` +/// To apply shear, scale, and rotation *without* applying translation, different functions are available: +/// ``` +/// # use bevy_transform::prelude::{GlobalTransform}; +/// # use bevy_math::prelude::Vec3; +/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.); +/// let local_direction = Vec3::new(1., 2., 3.); +/// let global_direction = global_transform.affine().transform_vector3(local_direction); +/// assert_eq!(global_direction, Vec3::new(1., 2., 3.)); +/// let roundtripped_local_direction = global_transform.affine().inverse().transform_vector3(global_direction); +/// assert_eq!(roundtripped_local_direction, local_direction); +/// ``` #[lua(kind = "Method", output(proxy))] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; @@ -210,21 +268,22 @@ use bevy_script_api::{ transform: bevy::transform::components::Transform, ) -> bevy::transform::components::GlobalTransform; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::GlobalTransform; + "#, r#" #[lua( - as_trait = "std::ops::Mul", + as_trait = "std::cmp::PartialEq", kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", + composite = "eq", + metamethod = "Eq", )] - fn mul( - self, - #[proxy] - global_transform: bevy::transform::components::GlobalTransform, - ) -> bevy::transform::components::GlobalTransform; + fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool; "#, r#" @@ -242,18 +301,6 @@ use bevy_script_api::{ transform: bevy::transform::components::Transform, ) -> bevy::transform::components::GlobalTransform; -"#, - r#" - - #[lua( - as_trait = "std::ops::Mul", - kind = "MetaFunction", - output(proxy), - composite = "mul", - metamethod = "Mul", - )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -269,6 +316,17 @@ struct GlobalTransform(); remote = "bevy::transform::components::Transform", functions[r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; + +"#, + r#" + #[lua( as_trait = "std::ops::Mul", kind = "MetaFunction", @@ -282,12 +340,6 @@ struct GlobalTransform(); global_transform: bevy::transform::components::GlobalTransform, ) -> bevy::transform::components::GlobalTransform; -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::transform::components::Transform; - "#, r#" @@ -298,7 +350,11 @@ struct GlobalTransform(); composite = "mul", metamethod = "Mul", )] - fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; + fn mul( + self, + #[proxy] + transform: bevy::transform::components::Transform, + ) -> bevy::transform::components::Transform; "#, r#" @@ -310,11 +366,7 @@ struct GlobalTransform(); composite = "mul", metamethod = "Mul", )] - fn mul( - self, - #[proxy] - transform: bevy::transform::components::Transform, - ) -> bevy::transform::components::Transform; + fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3; "#, r#" @@ -369,6 +421,17 @@ struct GlobalTransform(); scale: bevy::math::Vec3, ) -> bevy::transform::components::Transform; +"#, + r#" +/// Creates a new [`Transform`] that is equivalent to the given [isometry]. +/// [isometry]: Isometry3d + + #[lua(kind = "Function", output(proxy))] + fn from_isometry( + #[proxy] + iso: bevy::math::Isometry3d, + ) -> bevy::transform::components::Transform; + "#, r#" /// Returns this [`Transform`] with a new translation. @@ -603,12 +666,13 @@ struct GlobalTransform(); "#, r#" /// Transforms the given `point`, applying scale, rotation and translation. -/// If this [`Transform`] has a parent, this will transform a `point` that is -/// relative to the parent's [`Transform`] into one relative to this [`Transform`]. -/// If this [`Transform`] does not have a parent, this will transform a `point` -/// that is in global space into one relative to this [`Transform`]. -/// If you want to transform a `point` in global space to the local space of this [`Transform`], -/// consider using [`GlobalTransform::transform_point()`] instead. +/// If this [`Transform`] has an ancestor entity with a [`Transform`] component, +/// [`Transform::transform_point`] will transform a point in local space into its +/// parent transform's space. +/// If this [`Transform`] does not have a parent, [`Transform::transform_point`] will +/// transform a point in local space into worldspace coordinates. +/// If you always want to transform a point in local space to worldspace, or if you need +/// the inverse transformations, see [`GlobalTransform::transform_point()`]. #[lua(kind = "Method", output(proxy))] fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3; @@ -624,14 +688,17 @@ struct GlobalTransform(); "#, r#" +/// Get the [isometry] defined by this transform's rotation and translation, ignoring scale. +/// [isometry]: Isometry3d - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool; + #[lua(kind = "Method", output(proxy))] + fn to_isometry(&self) -> bevy::math::Isometry3d; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::transform::components::Transform; "#, r#" diff --git a/crates/bevy_script_api/src/providers/bevy_window.rs b/crates/bevy_script_api/src/providers/bevy_window.rs index 2c002018..3ec16478 100644 --- a/crates/bevy_script_api/src/providers/bevy_window.rs +++ b/crates/bevy_script_api/src/providers/bevy_window.rs @@ -2,8 +2,10 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] +use super::bevy_a11y::*; use super::bevy_ecs::*; use super::bevy_reflect::*; +use super::bevy_input::*; use super::bevy_math::*; extern crate self as bevy_script_api; use bevy_script_api::{ @@ -15,17 +17,6 @@ use bevy_script_api::{ remote = "bevy::window::prelude::CursorEntered", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::CursorEntered; @@ -35,27 +26,6 @@ use bevy_script_api::{ #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct CursorEntered { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, -} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::CursorIcon", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorIcon; - "#, r#" @@ -65,13 +35,7 @@ struct CursorEntered { composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &cursor::CursorIcon) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + fn eq(&self, #[proxy] other: &event::CursorEntered) -> bool; "#, r#" @@ -81,13 +45,22 @@ fn index(&self) -> String { } "#] )] -struct CursorIcon {} +struct CursorEntered { + #[lua(output(proxy))] + window: bevy::ecs::entity::Entity, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::window::prelude::CursorLeft", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -102,12 +75,6 @@ struct CursorIcon {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::CursorLeft; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -126,12 +93,6 @@ struct CursorLeft { remote = "bevy::window::prelude::CursorMoved", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::CursorMoved; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -140,6 +101,12 @@ struct CursorLeft { )] fn eq(&self, #[proxy] other: &event::CursorMoved) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::CursorMoved; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -196,13 +163,8 @@ struct FileDragAndDrop {} remote = "bevy::window::prelude::Ime", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::Ime) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -213,8 +175,13 @@ struct FileDragAndDrop {} "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::Ime) -> bool; "#, r#" @@ -231,12 +198,6 @@ struct Ime {} remote = "bevy::window::prelude::MonitorSelection", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -251,35 +212,6 @@ struct Ime {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::prelude::MonitorSelection; -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct MonitorSelection {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::window::prelude::ReceivedCharacter", - functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::ReceivedCharacter; - -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::ReceivedCharacter) -> bool; - "#, r#" @@ -294,23 +226,12 @@ fn index(&self) -> String { } "#] )] -struct ReceivedCharacter { - #[lua(output(proxy))] - window: bevy::ecs::entity::Entity, - #[lua(output(proxy))] - char: smol_str::SmolStr, -} +struct MonitorSelection {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), remote = "bevy::window::prelude::Window", functions[r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::Window; - -"#, - r#" /// Setting to true will attempt to maximize the window. /// Setting to false will attempt to un-maximize the window. @@ -325,6 +246,24 @@ struct ReceivedCharacter { #[lua(kind = "MutatingMethod")] fn set_minimized(&mut self, minimized: bool) -> (); +"#, + r#" +/// Calling this will attempt to start a drag-move of the window. +/// There is no guarantee that this will work unless the left mouse button was +/// pressed immediately before this function was called. + + #[lua(kind = "MutatingMethod")] + fn start_drag_move(&mut self) -> (); + +"#, + r#" +/// Calling this will attempt to start a drag-resize of the window. +/// There is no guarantee that this will work unless the left mouse button was +/// pressed immediately before this function was called. + + #[lua(kind = "MutatingMethod")] + fn start_drag_resize(&mut self, #[proxy] direction: bevy::math::CompassOctant) -> (); + "#, r#" /// The window's client area width in logical pixels. @@ -381,6 +320,12 @@ struct ReceivedCharacter { #[lua(kind = "Method")] fn scale_factor(&self) -> f32; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::Window; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -391,7 +336,7 @@ fn index(&self) -> String { )] struct Window { #[lua(output(proxy))] - cursor: bevy::window::Cursor, + cursor_options: bevy::window::CursorOptions, #[lua(output(proxy))] present_mode: bevy::window::PresentMode, #[lua(output(proxy))] @@ -430,6 +375,13 @@ struct Window { recognize_rotation_gesture: bool, recognize_doubletap_gesture: bool, recognize_pan_gesture: ReflectedValue, + movable_by_window_background: bool, + fullsize_content_view: bool, + has_shadow: bool, + titlebar_shown: bool, + titlebar_transparent: bool, + titlebar_show_title: bool, + titlebar_show_buttons: bool, } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( @@ -437,6 +389,12 @@ struct Window { remote = "bevy::window::prelude::WindowMoved", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowMoved; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -451,12 +409,6 @@ struct Window { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowMoved; - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -502,12 +454,6 @@ struct WindowMoved { monitor: bevy::window::prelude::MonitorSelection, ) -> (); -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::prelude::WindowPosition; - "#, r#" @@ -519,6 +465,12 @@ struct WindowMoved { )] fn eq(&self, #[proxy] other: &window::WindowPosition) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::prelude::WindowPosition; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -533,14 +485,11 @@ struct WindowPosition {} derive(clone), remote = "bevy::window::prelude::WindowResizeConstraints", functions[r#" +/// Checks if the constraints are valid. +/// Will output warnings if it isn't. - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; + #[lua(kind = "Method", output(proxy))] + fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; "#, r#" @@ -550,11 +499,14 @@ struct WindowPosition {} "#, r#" -/// Checks if the constraints are valid. -/// Will output warnings if it isn't. - #[lua(kind = "Method", output(proxy))] - fn check_constraints(&self) -> bevy::window::prelude::WindowResizeConstraints; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowResizeConstraints) -> bool; "#, r#" @@ -573,23 +525,52 @@ struct WindowResizeConstraints { #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowResized", + remote = "bevy::window::WindowEvent", functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowEvent; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; + fn eq(&self, #[proxy] other: &event::WindowEvent) -> bool; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct WindowEvent {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::window::WindowResized", + functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowResized; +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowResized) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -648,17 +629,6 @@ struct WindowCreated { remote = "bevy::window::WindowClosing", functions[r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowClosing) -> bool; - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowClosing; @@ -668,6 +638,17 @@ struct WindowCreated { #[lua(as_trait = "std::cmp::Eq", kind = "Method")] fn assert_receiver_is_total_eq(&self) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowClosing) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -689,6 +670,12 @@ struct WindowClosing { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowClosed; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" @@ -700,12 +687,6 @@ struct WindowClosing { )] fn eq(&self, #[proxy] other: &event::WindowClosed) -> bool; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -724,8 +705,13 @@ struct WindowClosed { remote = "bevy::window::WindowCloseRequested", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; "#, r#" @@ -736,13 +722,8 @@ struct WindowClosed { "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::WindowCloseRequested) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -762,8 +743,8 @@ struct WindowCloseRequested { remote = "bevy::window::WindowDestroyed", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowDestroyed; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -779,8 +760,8 @@ struct WindowCloseRequested { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowDestroyed; "#, r#" @@ -800,14 +781,14 @@ struct WindowDestroyed { remote = "bevy::window::RequestRedraw", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::RequestRedraw; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::RequestRedraw; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -874,18 +855,6 @@ struct WindowFocused { remote = "bevy::window::WindowOccluded", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowOccluded; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -894,6 +863,18 @@ struct WindowFocused { )] fn eq(&self, #[proxy] other: &event::WindowOccluded) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowOccluded; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -946,12 +927,6 @@ struct WindowScaleFactorChanged { remote = "bevy::window::WindowBackendScaleFactorChanged", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -960,6 +935,12 @@ struct WindowScaleFactorChanged { )] fn eq(&self, #[proxy] other: &event::WindowBackendScaleFactorChanged) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowBackendScaleFactorChanged; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -990,14 +971,14 @@ struct WindowBackendScaleFactorChanged { "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowThemeChanged; "#, r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowThemeChanged; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1019,25 +1000,25 @@ struct WindowThemeChanged { remote = "bevy::window::AppLifecycle", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::AppLifecycle; + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &event::AppLifecycle) -> bool; "#, r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::AppLifecycle; "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &event::AppLifecycle) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1061,6 +1042,18 @@ struct AppLifecycle {} remote = "bevy::window::PrimaryWindow", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PrimaryWindow; + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1069,6 +1062,24 @@ struct AppLifecycle {} )] fn eq(&self, #[proxy] other: &window::PrimaryWindow) -> bool; +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct PrimaryWindow {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::window::WindowTheme", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::WindowTheme; + "#, r#" @@ -1078,8 +1089,38 @@ struct AppLifecycle {} "#, r#" + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct WindowTheme {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::window::Monitor", + functions[r#" + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::PrimaryWindow; + fn clone(&self) -> bevy::window::Monitor; + +"#, + r#" +/// Returns the physical size of the monitor in pixels + + #[lua(kind = "Method", output(proxy))] + fn physical_size(&self) -> bevy::math::UVec2; "#, r#" @@ -1089,18 +1130,62 @@ fn index(&self) -> String { } "#] )] -struct PrimaryWindow {} +struct Monitor { + name: std::option::Option, + physical_height: u32, + physical_width: u32, + #[lua(output(proxy))] + physical_position: bevy::math::IVec2, + refresh_rate_millihertz: std::option::Option, + scale_factor: f64, + video_modes: ReflectedValue, +} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::WindowTheme", + remote = "bevy::window::VideoMode", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::WindowTheme; + fn clone(&self) -> bevy::window::VideoMode; + +"#, + r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct VideoMode { + #[lua(output(proxy))] + physical_size: bevy::math::UVec2, + bit_depth: u16, + refresh_rate_millihertz: u32, +} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::window::PrimaryMonitor", + functions[r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::PrimaryMonitor; "#, r#" +#[lua(kind="MetaMethod", metamethod="ToString")] +fn index(&self) -> String { + format!("{:?}", _self) +} +"#] +)] +struct PrimaryMonitor {} +#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +#[proxy( + derive(clone), + remote = "bevy::window::SystemCursorIcon", + functions[r#" #[lua( as_trait = "std::cmp::PartialEq", @@ -1108,7 +1193,13 @@ struct PrimaryWindow {} composite = "eq", metamethod = "Eq", )] - fn eq(&self, #[proxy] other: &window::WindowTheme) -> bool; + fn eq(&self, #[proxy] other: &system_cursor::SystemCursorIcon) -> bool; + +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::SystemCursorIcon; "#, r#" @@ -1124,7 +1215,7 @@ fn index(&self) -> String { } "#] )] -struct WindowTheme {} +struct SystemCursorIcon {} #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -1149,15 +1240,14 @@ struct WindowRef {} remote = "bevy::window::NormalizedWindowRef", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::NormalizedWindowRef; "#, r#" -/// Fetch the entity of this window reference - #[lua(kind = "Method", output(proxy))] - fn entity(&self) -> bevy::ecs::entity::Entity; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1172,9 +1262,10 @@ struct WindowRef {} "#, r#" +/// Fetch the entity of this window reference - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::NormalizedWindowRef; + #[lua(kind = "Method", output(proxy))] + fn entity(&self) -> bevy::ecs::entity::Entity; "#, r#" @@ -1188,11 +1279,11 @@ struct NormalizedWindowRef(); #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), - remote = "bevy::window::Cursor", + remote = "bevy::window::CursorOptions", functions[r#" #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::Cursor; + fn clone(&self) -> bevy::window::CursorOptions; "#, r#" @@ -1202,9 +1293,7 @@ fn index(&self) -> String { } "#] )] -struct Cursor { - #[lua(output(proxy))] - icon: bevy::window::prelude::CursorIcon, +struct CursorOptions { visible: bool, #[lua(output(proxy))] grab_mode: bevy::window::CursorGrabMode, @@ -1216,6 +1305,12 @@ struct Cursor { remote = "bevy::window::PresentMode", functions[r#" + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + +"#, + r#" + #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1230,12 +1325,6 @@ struct Cursor { #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::PresentMode; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1289,17 +1378,6 @@ struct WindowMode {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::WindowResolution; -"#, - r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; - "#, r#" /// Creates a new [`WindowResolution`]. @@ -1428,6 +1506,17 @@ struct WindowMode {} scale_factor_override: std::option::Option, ) -> (); +"#, + r#" + + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowResolution) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1443,12 +1532,6 @@ struct WindowResolution {} remote = "bevy::window::CompositeAlphaMode", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::CompositeAlphaMode; @@ -1463,6 +1546,12 @@ struct WindowResolution {} )] fn eq(&self, #[proxy] other: &window::CompositeAlphaMode) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1478,12 +1567,6 @@ struct CompositeAlphaMode {} remote = "bevy::window::EnabledButtons", functions[r#" - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::window::EnabledButtons; - -"#, - r#" - #[lua( as_trait = "std::cmp::PartialEq", kind = "MetaFunction", @@ -1492,6 +1575,12 @@ struct CompositeAlphaMode {} )] fn eq(&self, #[proxy] other: &window::EnabledButtons) -> bool; +"#, + r#" + + #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] + fn clone(&self) -> bevy::window::EnabledButtons; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1511,8 +1600,13 @@ struct EnabledButtons { remote = "bevy::window::WindowLevel", functions[r#" - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); + #[lua( + as_trait = "std::cmp::PartialEq", + kind = "MetaFunction", + composite = "eq", + metamethod = "Eq", + )] + fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; "#, r#" @@ -1523,13 +1617,8 @@ struct EnabledButtons { "#, r#" - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &window::WindowLevel) -> bool; + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); "#, r#" @@ -1574,6 +1663,13 @@ struct WindowLevel {} #[lua(kind = "MutatingMethod")] fn take_minimize_request(&mut self) -> std::option::Option; +"#, + r#" +/// Consumes the current move request, if it exists. This should only be called by window backends. + + #[lua(kind = "MutatingMethod")] + fn take_move_request(&mut self) -> bool; + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1592,12 +1688,6 @@ struct InternalWindowState {} #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] fn clone(&self) -> bevy::window::CursorGrabMode; -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - "#, r#" @@ -1609,6 +1699,12 @@ struct InternalWindowState {} )] fn eq(&self, #[proxy] other: &window::CursorGrabMode) -> bool; +"#, + r#" + + #[lua(as_trait = "std::cmp::Eq", kind = "Method")] + fn assert_receiver_is_total_eq(&self) -> (); + "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] @@ -1665,13 +1761,11 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { 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::() @@ -1681,6 +1775,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { >, >() .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() @@ -1696,9 +1791,13 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { .process_type::() .process_type::() .process_type::() + .process_type::() + .process_type::() + .process_type::() + .process_type::() .process_type::() .process_type::() - .process_type::() + .process_type::() .process_type::() .process_type::() .process_type::() @@ -1733,19 +1832,18 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { } fn register_with_app(&self, app: &mut bevy::app::App) { app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::< bevy::window::prelude::WindowResizeConstraints, >(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); @@ -1761,9 +1859,13 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyWindowAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); diff --git a/crates/bevy_script_api/src/providers/mod.rs b/crates/bevy_script_api/src/providers/mod.rs index 0f2e29ed..b0ca5e66 100644 --- a/crates/bevy_script_api/src/providers/mod.rs +++ b/crates/bevy_script_api/src/providers/mod.rs @@ -2,6 +2,7 @@ #![allow(clippy::all)] #![allow(unused, deprecated, dead_code)] #![cfg_attr(rustfmt, rustfmt_skip)] +pub mod bevy_a11y; pub mod bevy_ecs; pub mod bevy_transform; pub mod bevy_math; @@ -22,6 +23,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { &mut self, ctx: &mut Self::APITarget, ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> { + bevy_a11y::BevyA11YAPIProvider.attach_api(ctx)?; bevy_ecs::BevyEcsAPIProvider.attach_api(ctx)?; bevy_transform::BevyTransformAPIProvider.attach_api(ctx)?; bevy_math::BevyMathAPIProvider.attach_api(ctx)?; @@ -35,6 +37,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { } fn get_doc_fragment(&self) -> Option { [ + bevy_a11y::BevyA11YAPIProvider.get_doc_fragment(), bevy_ecs::BevyEcsAPIProvider.get_doc_fragment(), bevy_transform::BevyTransformAPIProvider.get_doc_fragment(), bevy_math::BevyMathAPIProvider.get_doc_fragment(), @@ -71,6 +74,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { Ok(()) } fn register_with_app(&self, app: &mut bevy::app::App) { + bevy_a11y::BevyA11YAPIProvider.register_with_app(app); bevy_ecs::BevyEcsAPIProvider.register_with_app(app); bevy_transform::BevyTransformAPIProvider.register_with_app(app); bevy_math::BevyMathAPIProvider.register_with_app(app); From d17006046fe45a321f5108c21c1d4a23cdb3dece Mon Sep 17 00:00:00 2001 From: makspll Date: Wed, 6 Nov 2024 22:41:22 +0000 Subject: [PATCH 06/15] pin git again --- crates/bevy_api_gen/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_api_gen/Cargo.toml b/crates/bevy_api_gen/Cargo.toml index b286f45d..501fca03 100644 --- a/crates/bevy_api_gen/Cargo.toml +++ b/crates/bevy_api_gen/Cargo.toml @@ -43,7 +43,7 @@ overrideCommand = ["cargo", "+nightly-2024-11-05", "a", "--message-format=json"] [dependencies] log = "0.4" env_logger = "0.11" -rustc_plugin = { path = "../../../rustc_plugin/crates/rustc_plugin" } +rustc_plugin = { git = "https://github.com/makspll/rustc_plugin", branch = "feature/rust-1.82.0" } indexmap = "2" tempdir = "0.3" cargo_metadata = "0.18" From 8f9338970b9b954a940c8947e528c600d65f0acf Mon Sep 17 00:00:00 2001 From: makspll Date: Wed, 6 Nov 2024 22:49:04 +0000 Subject: [PATCH 07/15] fix more errors --- crates/bevy_script_api/Cargo.toml | 1 - .../src/providers/bevy_input.rs | 155 +++++----- .../src/providers/bevy_math.rs | 20 +- .../src/providers/bevy_reflect.rs | 290 +++++++++--------- 4 files changed, 233 insertions(+), 233 deletions(-) diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml index 1e49c377..d4ed591f 100644 --- a/crates/bevy_script_api/Cargo.toml +++ b/crates/bevy_script_api/Cargo.toml @@ -28,7 +28,6 @@ bevy = { workspace = true, default-features = false, features = [ "bevy_sprite", "file_watcher", "multi_threaded", - "bevy_reflect", ] } uuid = "1.10" bevy_mod_scripting_core = { workspace = true } diff --git a/crates/bevy_script_api/src/providers/bevy_input.rs b/crates/bevy_script_api/src/providers/bevy_input.rs index 72d379ab..973bde55 100644 --- a/crates/bevy_script_api/src/providers/bevy_input.rs +++ b/crates/bevy_script_api/src/providers/bevy_input.rs @@ -13,21 +13,22 @@ use bevy_script_api::{ #[proxy( derive(), remote = "bevy::input::gamepad::Gamepad", - functions[r#" -/// Returns the USB vendor ID as assigned by the USB-IF, if available. + functions[ + // r#" +// /// Returns the USB vendor ID as assigned by the USB-IF, if available. - #[lua(kind = "Method")] - fn vendor_id(&self) -> std::option::Option; +// #[lua(kind = "Method")] +// fn vendor_id(&self) -> std::option::Option; -"#, - r#" -/// Returns the USB product ID as assigned by the [vendor], if available. -/// [vendor]: Self::vendor_id +// "#, +// r#" +// /// Returns the USB product ID as assigned by the [vendor], if available. +// /// [vendor]: Self::vendor_id - #[lua(kind = "Method")] - fn product_id(&self) -> std::option::Option; +// #[lua(kind = "Method")] +// fn product_id(&self) -> std::option::Option; -"#, +// "#, r#" /// Returns the left stick as a [`Vec2`] @@ -49,37 +50,37 @@ use bevy_script_api::{ fn dpad(&self) -> bevy::math::Vec2; "#, - r#" -/// Returns `true` if the [`GamepadButton`] has been pressed. +// r#" +// /// Returns `true` if the [`GamepadButton`] has been pressed. - #[lua(kind = "Method")] - fn pressed(&self, #[proxy] button_type: bevy::input::gamepad::GamepadButton) -> bool; +// #[lua(kind = "Method")] +// fn pressed(&self, #[proxy] button_type: bevy::input::gamepad::GamepadButton) -> bool; -"#, - r#" -/// Returns `true` if the [`GamepadButton`] has been pressed during the current frame. -/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. +// "#, +// 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(kind = "Method")] - fn just_pressed( - &self, - #[proxy] - button_type: bevy::input::gamepad::GamepadButton, - ) -> bool; +// #[lua(kind = "Method")] +// fn just_pressed( +// &self, +// #[proxy] +// button_type: bevy::input::gamepad::GamepadButton, +// ) -> bool; -"#, - r#" -/// Returns `true` if the [`GamepadButton`] has been released during the current frame. -/// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. +// "#, +// 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(kind = "Method")] - fn just_released( - &self, - #[proxy] - button_type: bevy::input::gamepad::GamepadButton, - ) -> bool; +// #[lua(kind = "Method")] +// fn just_released( +// &self, +// #[proxy] +// button_type: bevy::input::gamepad::GamepadButton, +// ) -> bool; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -824,45 +825,45 @@ fn index(&self) -> String { "#] )] struct GamepadEvent {} -#[derive(bevy_mod_scripting_lua_derive::LuaProxy)] -#[proxy( - derive(clone), - remote = "bevy::input::gamepad::GamepadInfo", - functions[r#" - - #[lua( - as_trait = "std::cmp::PartialEq", - kind = "MetaFunction", - composite = "eq", - metamethod = "Eq", - )] - fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; - -"#, - r#" - - #[lua(as_trait = "std::cmp::Eq", kind = "Method")] - fn assert_receiver_is_total_eq(&self) -> (); - -"#, - r#" - - #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] - fn clone(&self) -> bevy::input::gamepad::GamepadInfo; - -"#, - r#" -#[lua(kind="MetaMethod", metamethod="ToString")] -fn index(&self) -> String { - format!("{:?}", _self) -} -"#] -)] -struct GamepadInfo { - name: std::string::String, - vendor_id: std::option::Option, - product_id: std::option::Option, -} +// #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] +// #[proxy( +// derive(clone), +// remote = "bevy::input::gamepad::GamepadInfo", +// functions[r#" + +// #[lua( +// as_trait = "std::cmp::PartialEq", +// kind = "MetaFunction", +// composite = "eq", +// metamethod = "Eq", +// )] +// fn eq(&self, #[proxy] other: &gamepad::GamepadInfo) -> bool; + +// "#, +// r#" + +// #[lua(as_trait = "std::cmp::Eq", kind = "Method")] +// fn assert_receiver_is_total_eq(&self) -> (); + +// "#, +// r#" + +// #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))] +// fn clone(&self) -> bevy::input::gamepad::GamepadInfo; + +// "#, +// r#" +// #[lua(kind="MetaMethod", metamethod="ToString")] +// fn index(&self) -> String { +// format!("{:?}", _self) +// } +// "#] +// )] +// struct GamepadInfo { +// name: std::string::String, +// vendor_id: std::option::Option, +// product_id: std::option::Option, +// } #[derive(bevy_mod_scripting_lua_derive::LuaProxy)] #[proxy( derive(clone), @@ -1818,7 +1819,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { >, >() .process_type::() - .process_type::() + // .process_type::() .process_type::() .process_type::() .process_type::() @@ -1898,7 +1899,7 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider { app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); + // app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::(); app.register_foreign_lua_type::< diff --git a/crates/bevy_script_api/src/providers/bevy_math.rs b/crates/bevy_script_api/src/providers/bevy_math.rs index e6c8fd2f..62142da4 100644 --- a/crates/bevy_script_api/src/providers/bevy_math.rs +++ b/crates/bevy_script_api/src/providers/bevy_math.rs @@ -2829,13 +2829,13 @@ struct Capsule2d { fn sagitta(&self) -> f32; "#, - r#" -/// Returns the area of this sector +// r#" +// /// Returns the area of this sector - #[lua(kind = "Method")] - fn area(&self) -> f32; +// #[lua(kind = "Method")] +// fn area(&self) -> f32; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -2946,13 +2946,13 @@ struct CircularSector { fn sagitta(&self) -> f32; "#, - r#" -/// Returns the area of this segment +// r#" +// /// Returns the area of this segment - #[lua(kind = "Method")] - fn area(&self) -> f32; +// #[lua(kind = "Method")] +// fn area(&self) -> f32; -"#, +// "#, r#" #[lua( diff --git a/crates/bevy_script_api/src/providers/bevy_reflect.rs b/crates/bevy_script_api/src/providers/bevy_reflect.rs index 02453c8d..6fe8ad6a 100644 --- a/crates/bevy_script_api/src/providers/bevy_reflect.rs +++ b/crates/bevy_script_api/src/providers/bevy_reflect.rs @@ -23,21 +23,21 @@ use bevy_script_api::{ fn new(v: bool) -> std::sync::atomic::AtomicBool; "#, - 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(kind = "Method")] - fn into_inner(self) -> bool; - -"#, +// 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(kind = "Method")] +// fn into_inner(self) -> bool; + +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -62,21 +62,21 @@ struct AtomicBool {} fn new(v: i16) -> std::sync::atomic::AtomicI16; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> i16; +// #[lua(kind = "Method")] +// fn into_inner(self) -> i16; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -101,21 +101,21 @@ struct AtomicI16 {} fn new(v: i32) -> std::sync::atomic::AtomicI32; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> i32; +// #[lua(kind = "Method")] +// fn into_inner(self) -> i32; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -140,21 +140,21 @@ struct AtomicI32 {} fn new(v: i64) -> std::sync::atomic::AtomicI64; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> i64; +// #[lua(kind = "Method")] +// fn into_inner(self) -> i64; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -179,21 +179,21 @@ struct AtomicI64 {} fn new(v: i8) -> std::sync::atomic::AtomicI8; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> i8; +// #[lua(kind = "Method")] +// fn into_inner(self) -> i8; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -218,21 +218,21 @@ struct AtomicI8 {} fn new(v: isize) -> std::sync::atomic::AtomicIsize; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> isize; +// #[lua(kind = "Method")] +// fn into_inner(self) -> isize; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -257,21 +257,21 @@ struct AtomicIsize {} fn new(v: u16) -> std::sync::atomic::AtomicU16; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> u16; +// #[lua(kind = "Method")] +// fn into_inner(self) -> u16; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -296,21 +296,21 @@ struct AtomicU16 {} fn new(v: u32) -> std::sync::atomic::AtomicU32; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> u32; +// #[lua(kind = "Method")] +// fn into_inner(self) -> u32; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -335,21 +335,21 @@ struct AtomicU32 {} fn new(v: u64) -> std::sync::atomic::AtomicU64; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> u64; +// #[lua(kind = "Method")] +// fn into_inner(self) -> u64; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -374,21 +374,21 @@ struct AtomicU64 {} fn new(v: u8) -> std::sync::atomic::AtomicU8; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> u8; +// #[lua(kind = "Method")] +// fn into_inner(self) -> u8; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { @@ -413,21 +413,21 @@ struct AtomicU8 {} fn new(v: usize) -> std::sync::atomic::AtomicUsize; "#, - 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); -/// ``` +// 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(kind = "Method")] - fn into_inner(self) -> usize; +// #[lua(kind = "Method")] +// fn into_inner(self) -> usize; -"#, +// "#, r#" #[lua(kind="MetaMethod", metamethod="ToString")] fn index(&self) -> String { From 06b657a140172a54efd5be9725ada166103a8bdd Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 8 Nov 2024 19:15:07 +0000 Subject: [PATCH 08/15] bump macro tests --- crates/macro_tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/macro_tests/Cargo.toml b/crates/macro_tests/Cargo.toml index dd5a02b4..9cc1a7bd 100644 --- a/crates/macro_tests/Cargo.toml +++ b/crates/macro_tests/Cargo.toml @@ -15,7 +15,7 @@ debug = false [dev-dependencies] trybuild = "1.0" -bevy = { version = "0.15", default-features = false } +bevy = { version = "0.15.0-rc.2", default-features = false } bevy_mod_scripting = { path = "../../", features = [ "lua", "lua_script_api", From 38d4137b5da94e79eb055429872dd1e6cde44926 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 8 Nov 2024 19:20:36 +0000 Subject: [PATCH 09/15] clippy fixes to bevy api gen --- crates/bevy_api_gen/src/meta.rs | 2 +- crates/bevy_api_gen/src/passes/find_methods_and_fields.rs | 2 +- crates/bevy_api_gen/src/template.rs | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/bevy_api_gen/src/meta.rs b/crates/bevy_api_gen/src/meta.rs index 3f85dd30..a9861da3 100644 --- a/crates/bevy_api_gen/src/meta.rs +++ b/crates/bevy_api_gen/src/meta.rs @@ -94,7 +94,7 @@ impl MetaLoader { let cache = self.cache.borrow(); if cache.contains_key(crate_name) { trace!("Loading meta from cache for: {}", crate_name); - return cache.get(crate_name).cloned(); + cache.get(crate_name).cloned() } else { trace!("Loading meta from filesystem for: {}", crate_name); drop(cache); diff --git a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs index 20e4cec9..8034681a 100644 --- a/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs +++ b/crates/bevy_api_gen/src/passes/find_methods_and_fields.rs @@ -391,7 +391,7 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>( ) -> bool { trace!("Checkign type is supported as non proxy return val: '{ty:?}' with param_env: '{param_env:?}'"); if let TyKind::Ref(region, _, _) = ty.kind() { - if !region.get_name().is_some_and(|rn| rn.as_str() == "'static") { + if region.get_name().is_none_or(|rn| rn.as_str() != "'static") { return false; } } diff --git a/crates/bevy_api_gen/src/template.rs b/crates/bevy_api_gen/src/template.rs index ce8774e1..878c7dba 100644 --- a/crates/bevy_api_gen/src/template.rs +++ b/crates/bevy_api_gen/src/template.rs @@ -195,9 +195,8 @@ pub(crate) fn configure_tera_env(tera: &mut Tera, crate_name: &str) { let file = syn::parse_file(&str) .map_err(|e| tera::Error::msg(e.to_string())) - .map_err(|e| { + .inspect_err(|e| { log::error!("prettyplease error on input: ```\n{}\n```", str); - e })?; let out = prettyplease::unparse(&file); From 2f3d42244f7477f47ec7ec85ca028dcbde903190 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 8 Nov 2024 19:22:39 +0000 Subject: [PATCH 10/15] more bevy api gen clippy fixes --- crates/bevy_api_gen/src/context.rs | 14 +++++++------- crates/bevy_api_gen/src/template.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bevy_api_gen/src/context.rs b/crates/bevy_api_gen/src/context.rs index dd18021d..498a958c 100644 --- a/crates/bevy_api_gen/src/context.rs +++ b/crates/bevy_api_gen/src/context.rs @@ -138,13 +138,13 @@ impl CachedTraits { .all(|t| self.std_source_traits.contains_key(*t)) } - pub(crate) fn missing_std_source_traits(&self) -> Vec { - STD_SOURCE_TRAITS - .iter() - .filter(|t| !self.std_source_traits.contains_key(**t)) - .map(|s| (*s).to_owned()) - .collect() - } + // pub(crate) fn missing_std_source_traits(&self) -> Vec { + // STD_SOURCE_TRAITS + // .iter() + // .filter(|t| !self.std_source_traits.contains_key(**t)) + // .map(|s| (*s).to_owned()) + // .collect() + // } } #[derive(Clone, Debug)] diff --git a/crates/bevy_api_gen/src/template.rs b/crates/bevy_api_gen/src/template.rs index 878c7dba..e9219d00 100644 --- a/crates/bevy_api_gen/src/template.rs +++ b/crates/bevy_api_gen/src/template.rs @@ -195,7 +195,7 @@ pub(crate) fn configure_tera_env(tera: &mut Tera, crate_name: &str) { let file = syn::parse_file(&str) .map_err(|e| tera::Error::msg(e.to_string())) - .inspect_err(|e| { + .inspect_err(|_| { log::error!("prettyplease error on input: ```\n{}\n```", str); })?; From 2e83f2d6f07896919737a74b1cf110c4a4daa9ba Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 9 Nov 2024 12:55:57 +0000 Subject: [PATCH 11/15] Update game of life examples --- examples/lua/game_of_life.rs | 23 ++++++++++------------- examples/rhai/game_of_life.rs | 23 ++++++++++------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/examples/lua/game_of_life.rs b/examples/lua/game_of_life.rs index 11482c2f..1048e0b7 100644 --- a/examples/lua/game_of_life.rs +++ b/examples/lua/game_of_life.rs @@ -86,18 +86,15 @@ pub fn setup( let script_path = bevy_mod_scripting_lua::lua_path!("game_of_life"); - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands - .spawn(SpriteBundle { - texture: assets.add(image), - sprite: Sprite { - custom_size: Some(Vec2::new( - settings.display_grid_dimensions.0 as f32, - settings.display_grid_dimensions.1 as f32, - )), - color: Color::srgb(1.0, 0.388, 0.278), // TOMATO - ..Default::default() - }, + .spawn(Sprite { + image: assets.add(image), + custom_size: Some(Vec2::new( + settings.display_grid_dimensions.0 as f32, + settings.display_grid_dimensions.1 as f32, + )), + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }) .insert(LifeState { @@ -156,11 +153,11 @@ pub fn sync_window_size( /// Runs after LifeState components are updated, updates their rendered representation pub fn update_rendered_state( mut assets: ResMut>, - query: Query<(&LifeState, &Handle)>, + query: Query<(&LifeState, &Sprite)>, ) { for (new_state, old_rendered_state) in query.iter() { let old_rendered_state = assets - .get_mut(old_rendered_state) + .get_mut(&old_rendered_state.image) .expect("World is not setup correctly"); old_rendered_state.data = new_state.cells.clone(); diff --git a/examples/rhai/game_of_life.rs b/examples/rhai/game_of_life.rs index aa203448..a7a5eff9 100644 --- a/examples/rhai/game_of_life.rs +++ b/examples/rhai/game_of_life.rs @@ -91,18 +91,15 @@ pub fn setup( let script_path = "scripts/game_of_life.rhai"; - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d); commands - .spawn(SpriteBundle { - texture: assets.add(image), - sprite: Sprite { - custom_size: Some(Vec2::new( - settings.display_grid_dimensions.0 as f32, - settings.display_grid_dimensions.1 as f32, - )), - color: Color::srgb(1.0, 0.388, 0.278), // TOMATO - ..Default::default() - }, + .spawn(Sprite { + image: assets.add(image), + custom_size: Some(Vec2::new( + settings.display_grid_dimensions.0 as f32, + settings.display_grid_dimensions.1 as f32, + )), + color: Color::srgb(1.0, 0.388, 0.278), // TOMATO ..Default::default() }) .insert(LifeState { @@ -161,11 +158,11 @@ pub fn sync_window_size( /// Runs after LifeState components are updated, updates their rendered representation pub fn update_rendered_state( mut assets: ResMut>, - query: Query<(&LifeState, &Handle)>, + query: Query<(&LifeState, &Sprite)>, ) { for (new_state, old_rendered_state) in query.iter() { let old_rendered_state = assets - .get_mut(old_rendered_state) + .get_mut(&old_rendered_state.image) .expect("World is not setup correctly"); old_rendered_state.data = new_state.cells.clone(); From fdeab587f9bca7d31d40e56a98284ee0df23f1cc Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 9 Nov 2024 13:00:35 +0000 Subject: [PATCH 12/15] fix clippy --- Cargo.toml | 39 ++++++++++--------- crates/bevy_script_api/src/common/bevy/mod.rs | 2 +- crates/bevy_script_api/src/lua/util.rs | 2 +- crates/bevy_script_api/src/sub_reflect.rs | 30 +++++--------- .../bevy_mod_scripting_lua/src/assets.rs | 2 +- .../bevy_mod_scripting_lua/src/docs.rs | 6 +-- 6 files changed, 36 insertions(+), 45 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2902d741..f8a3a5e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,25 +111,26 @@ codegen-units = 8 incremental = false debug = false -[[example]] -name = "console_integration_lua" -path = "examples/lua/console_integration.rs" -required-features = [ - "lua54", - "lua_script_api", - "bevy/file_watcher", - "bevy/multi_threaded", -] - -[[example]] -name = "console_integration_rhai" -path = "examples/rhai/console_integration.rs" -required-features = [ - "rhai", - "rhai_script_api", - "bevy/file_watcher", - "bevy/multi_threaded", -] +# TODO: bump once bevy is released and the lib is updated +# [[example]] +# name = "console_integration_lua" +# path = "examples/lua/console_integration.rs" +# required-features = [ +# "lua54", +# "lua_script_api", +# "bevy/file_watcher", +# "bevy/multi_threaded", +# ] + +# [[example]] +# name = "console_integration_rhai" +# path = "examples/rhai/console_integration.rs" +# required-features = [ +# "rhai", +# "rhai_script_api", +# "bevy/file_watcher", +# "bevy/multi_threaded", +# ] [[example]] name = "complex_game_loop_lua" diff --git a/crates/bevy_script_api/src/common/bevy/mod.rs b/crates/bevy_script_api/src/common/bevy/mod.rs index 56dbc87e..6df4b72e 100644 --- a/crates/bevy_script_api/src/common/bevy/mod.rs +++ b/crates/bevy_script_api/src/common/bevy/mod.rs @@ -243,7 +243,7 @@ impl ScriptWorld { bevy::reflect::TypeInfo::List(_) => component_data.insert(&mut entity_ref, &DynamicList::default(), ®istry_lock), bevy::reflect::TypeInfo::Array(_) => component_data.insert(&mut entity_ref, &DynamicArray::new(Box::new([])), ®istry_lock), bevy::reflect::TypeInfo::Map(_) => component_data.insert(&mut entity_ref, &DynamicMap::default(), ®istry_lock), - bevy::reflect::TypeInfo::Set(set_info) => component_data.insert(&mut entity_ref, &DynamicSet::default(), ®istry_lock), + bevy::reflect::TypeInfo::Set(_) => component_data.insert(&mut entity_ref, &DynamicSet::default(), ®istry_lock), bevy::reflect::TypeInfo::Opaque(_) => component_data.insert(&mut entity_ref, comp_type.data::().ok_or_else(|| ScriptError::Other(format!("Component {} is a value or dynamic type with no `ReflectDefault` type_data, cannot instantiate sensible value",comp_type.short_name())))? diff --git a/crates/bevy_script_api/src/lua/util.rs b/crates/bevy_script_api/src/lua/util.rs index f6467a57..6c611e0b 100644 --- a/crates/bevy_script_api/src/lua/util.rs +++ b/crates/bevy_script_api/src/lua/util.rs @@ -333,7 +333,7 @@ macro_rules! impl_tealr_generic{ panic!("This should never be called, I am a dummy implementation"); } - fn try_apply(&mut self, value: &dyn ::bevy::prelude::PartialReflect) -> std::result::Result<(), ::bevy::reflect::ApplyError> { + fn try_apply(&mut self, _value: &dyn ::bevy::prelude::PartialReflect) -> std::result::Result<(), ::bevy::reflect::ApplyError> { panic!("This should never be called, I am a dummy implementation"); } diff --git a/crates/bevy_script_api/src/sub_reflect.rs b/crates/bevy_script_api/src/sub_reflect.rs index ec1d14d4..1d9f8986 100644 --- a/crates/bevy_script_api/src/sub_reflect.rs +++ b/crates/bevy_script_api/src/sub_reflect.rs @@ -125,8 +125,7 @@ impl ReflectionPathElement { ReflectionPathElement::FieldAccess(field) => match base.reflect_ref() { ReflectRef::Struct(s) => s .field(field) - .map(PartialReflect::try_as_reflect) - .flatten() + .and_then(PartialReflect::try_as_reflect) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), @@ -139,32 +138,28 @@ impl ReflectionPathElement { ReflectionPathElement::IndexAccess(index) => match base.reflect_ref() { ReflectRef::TupleStruct(s) => s .field(*index) - .map(PartialReflect::try_as_reflect) - .flatten() + .and_then(PartialReflect::try_as_reflect) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectRef::Tuple(s) => s .field(*index) - .map(PartialReflect::try_as_reflect) - .flatten() + .and_then(PartialReflect::try_as_reflect) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectRef::List(s) => s .get(*index) - .map(PartialReflect::try_as_reflect) - .flatten() + .and_then(PartialReflect::try_as_reflect) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectRef::Array(s) => s .get(*index) - .map(PartialReflect::try_as_reflect) - .flatten() + .and_then(PartialReflect::try_as_reflect) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), @@ -186,8 +181,7 @@ impl ReflectionPathElement { ReflectionPathElement::FieldAccess(field) => match base.reflect_mut() { ReflectMut::Struct(s) => s .field_mut(field) - .map(PartialReflect::try_as_reflect_mut) - .flatten() + .and_then(PartialReflect::try_as_reflect_mut) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such field".to_owned(), @@ -200,32 +194,28 @@ impl ReflectionPathElement { ReflectionPathElement::IndexAccess(index) => match base.reflect_mut() { ReflectMut::TupleStruct(s) => s .field_mut(*index) - .map(PartialReflect::try_as_reflect_mut) - .flatten() + .and_then(PartialReflect::try_as_reflect_mut) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectMut::Tuple(s) => s .field_mut(*index) - .map(PartialReflect::try_as_reflect_mut) - .flatten() + .and_then(PartialReflect::try_as_reflect_mut) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectMut::List(s) => s .get_mut(*index) - .map(PartialReflect::try_as_reflect_mut) - .flatten() + .and_then(PartialReflect::try_as_reflect_mut) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), }), ReflectMut::Array(s) => s .get_mut(*index) - .map(PartialReflect::try_as_reflect_mut) - .flatten() + .and_then(PartialReflect::try_as_reflect_mut) .ok_or_else(|| ReflectionError::InvalidReflectionPath { path: self.to_string(), msg: "No such element".to_owned(), diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index e3043196..7e3e50d7 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -1,5 +1,5 @@ use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, + asset::{io::Reader, Asset, AssetLoader}, reflect::TypePath, utils::BoxedFuture, }; diff --git a/crates/languages/bevy_mod_scripting_lua/src/docs.rs b/crates/languages/bevy_mod_scripting_lua/src/docs.rs index 8bdd53be..9fbb42b0 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/docs.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/docs.rs @@ -101,10 +101,10 @@ impl DocFragment for LuaDocFragment { tw.given_types.iter_mut().for_each(|tg| { if let TypeGenerator::Record(rg) = tg { rg.fields - .sort_by(|f1, f2| f1.name.deref().cmp(&f2.name.deref())); + .sort_by(|f1, f2| f1.name.deref().cmp(f2.name.deref())); rg.fields.dedup_by(|a, b| a.name == b.name); rg.static_fields - .sort_by(|f1, f2| f1.name.deref().cmp(&f2.name.deref())); + .sort_by(|f1, f2| f1.name.deref().cmp(f2.name.deref())); rg.static_fields.dedup_by(|a, b| a.name == b.name); for field in rg.fields.iter_mut().chain(rg.static_fields.iter_mut()) { escape_name(&mut field.name); @@ -217,7 +217,7 @@ fn escape_name(raw: &mut NameContainer) { "local", // Declarations "record", // Teal extra ]; - let Ok(name) = str::from_utf8(&raw) else { + let Ok(name) = str::from_utf8(raw) else { return; }; if KEYWORD_FIELDS.contains(&name) { From c4681156a4c19df6c18191317bf89a4686e0913d Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 9 Nov 2024 13:07:19 +0000 Subject: [PATCH 13/15] fix more clippy --- crates/languages/bevy_mod_scripting_rhai/src/assets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs index 5d3c82e2..36b92498 100644 --- a/crates/languages/bevy_mod_scripting_rhai/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rhai/src/assets.rs @@ -1,5 +1,5 @@ use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt, LoadContext}, + asset::{io::Reader, Asset, AssetLoader, LoadContext}, reflect::TypePath, }; From fdb15bfa3cd5becc722120b8dad40a46730da2cb Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 9 Nov 2024 13:41:58 +0000 Subject: [PATCH 14/15] fix more clippy --- crates/languages/bevy_mod_scripting_rune/src/assets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs index d1672849..e5d0f96a 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/assets.rs @@ -1,6 +1,6 @@ use anyhow::Error; use bevy::{ - asset::{io::Reader, Asset, AssetLoader, AsyncReadExt}, + asset::{io::Reader, Asset, AssetLoader}, reflect::TypePath, }; use bevy_mod_scripting_core::prelude::*; From e86cbaf3394dcfd32befa0f88e49de4977217bca Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 9 Nov 2024 15:34:07 +0000 Subject: [PATCH 15/15] bump versions to alpha --- Cargo.toml | 14 +++++++------- crates/bevy_event_priority/Cargo.toml | 2 +- crates/bevy_mod_scripting_common/Cargo.toml | 2 +- crates/bevy_mod_scripting_core/Cargo.toml | 4 ++-- crates/bevy_script_api/Cargo.toml | 8 ++++---- crates/languages/bevy_mod_scripting_lua/Cargo.toml | 2 +- .../bevy_mod_scripting_lua_derive/Cargo.toml | 4 ++-- .../languages/bevy_mod_scripting_rhai/Cargo.toml | 2 +- .../bevy_mod_scripting_rhai_derive/Cargo.toml | 4 ++-- .../languages/bevy_mod_scripting_rune/Cargo.toml | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f8a3a5e6..8d83969b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -63,16 +63,16 @@ rune = ["bevy_mod_scripting_rune"] [dependencies] bevy = { workspace = true } bevy_mod_scripting_core = { workspace = true } -bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.7.1", optional = true } -bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.7.1", optional = true } -bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.7.1", optional = true } -bevy_script_api = { path = "crates/bevy_script_api", version = "0.7.1", optional = true } +bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.8.0-alpha.0", optional = true } +bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.8.0-alpha.0", optional = true } +bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.8.0-alpha.0", optional = true } +bevy_script_api = { path = "crates/bevy_script_api", version = "0.8.0-alpha.0", optional = true } [workspace.dependencies] bevy = { version = "0.15.0-rc.2", default-features = false } -bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.7.1" } -bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.7.1" } +bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.8.0-alpha.0" } +bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.8.0-alpha.0" } [dev-dependencies] bevy = { workspace = true, default-features = true } diff --git a/crates/bevy_event_priority/Cargo.toml b/crates/bevy_event_priority/Cargo.toml index d8e26084..f13818d2 100644 --- a/crates/bevy_event_priority/Cargo.toml +++ b/crates/bevy_event_priority/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_event_priority" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/bevy_mod_scripting_common/Cargo.toml b/crates/bevy_mod_scripting_common/Cargo.toml index 01ed7aa5..a9f4032e 100644 --- a/crates/bevy_mod_scripting_common/Cargo.toml +++ b/crates/bevy_mod_scripting_common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_common" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/bevy_mod_scripting_core/Cargo.toml b/crates/bevy_mod_scripting_core/Cargo.toml index 68847b7a..402f7c27 100644 --- a/crates/bevy_mod_scripting_core/Cargo.toml +++ b/crates/bevy_mod_scripting_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_core" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -32,7 +32,7 @@ bevy = { workspace = true, default-features = false, features = [ "bevy_text", "bevy_sprite", ] } -bevy_event_priority = { path = "../bevy_event_priority", version = "0.7.1" } +bevy_event_priority = { path = "../bevy_event_priority", version = "0.8.0-alpha.0" } thiserror = "1.0.31" paste = "1.0.7" parking_lot = "0.12.1" diff --git a/crates/bevy_script_api/Cargo.toml b/crates/bevy_script_api/Cargo.toml index d4ed591f..caaf350d 100644 --- a/crates/bevy_script_api/Cargo.toml +++ b/crates/bevy_script_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_script_api" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -35,8 +35,8 @@ parking_lot = "0.12.1" paste = "1.0.7" thiserror = "1.0.32" # lua -bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", version = "0.7.1", optional = true } -bevy_mod_scripting_lua_derive = { path = "../languages/bevy_mod_scripting_lua_derive", version = "0.7.1", optional = true } -bevy_mod_scripting_rhai = { path = "../languages/bevy_mod_scripting_rhai", version = "0.7.1", optional = true } +bevy_mod_scripting_lua = { path = "../languages/bevy_mod_scripting_lua", version = "0.8.0-alpha.0", optional = true } +bevy_mod_scripting_lua_derive = { path = "../languages/bevy_mod_scripting_lua_derive", version = "0.8.0-alpha.0", optional = true } +bevy_mod_scripting_rhai = { path = "../languages/bevy_mod_scripting_rhai", version = "0.8.0-alpha.0", optional = true } smol_str = "0.2" allocator-api2 = "0.2" diff --git a/crates/languages/bevy_mod_scripting_lua/Cargo.toml b/crates/languages/bevy_mod_scripting_lua/Cargo.toml index 3ba93e1c..35cde604 100644 --- a/crates/languages/bevy_mod_scripting_lua/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_lua" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml index c95fe287..9cddc788 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_lua_derive" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -23,7 +23,7 @@ path = "src/lib.rs" proc-macro = true [dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.7.1" } +bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.8.0-alpha.0" } paste = "1.0.7" darling = "0.20" syn = { version = "2.0.38", features = ["full", "fold", "extra-traits"] } diff --git a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml index 3f2c8799..fb5abd3e 100644 --- a/crates/languages/bevy_mod_scripting_rhai/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rhai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rhai" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml index f06a35aa..2e60540d 100644 --- a/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rhai_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rhai_derive" -version = "0.7.1" +version = "0.8.0-alpha.0" authors = ["Maksymilian Mozolewski "] edition = "2021" license = "MIT OR Apache-2.0" @@ -17,7 +17,7 @@ path = "src/lib.rs" proc-macro = true [dependencies] -bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.7.1" } +bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.8.0-alpha.0" } paste = "1.0.7" syn = { version = "1.0.57", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" diff --git a/crates/languages/bevy_mod_scripting_rune/Cargo.toml b/crates/languages/bevy_mod_scripting_rune/Cargo.toml index e86f4f8f..2bfcb903 100644 --- a/crates/languages/bevy_mod_scripting_rune/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_rune/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_scripting_rune" -version = "0.7.1" +version = "0.8.0-alpha.0" edition = "2021" license = "MIT OR Apache-2.0" description = "Necessary functionality for Rune support with bevy_mod_scripting"