Fix #6: Rendering Shared 3D Models #10

Merged
SeanOMik merged 11 commits from bug/6-rendering-shared-models into main 2024-04-01 15:03:02 +00:00
4 changed files with 37 additions and 18 deletions
Showing only changes of commit a2aac25249 - Show all commits

View File

@ -17,6 +17,24 @@ pub trait Bundle {
fn is_dynamic(&self) -> bool; fn is_dynamic(&self) -> bool;
} }
impl Bundle for () {
fn type_ids(&self) -> Vec<DynTypeId> {
vec![DynTypeId::of::<()>()]
}
fn info(&self) -> Vec<ComponentInfo> {
vec![ComponentInfo::new::<()>()]
}
fn take(self, mut f: impl FnMut(NonNull<u8>, DynTypeId, usize)) {
f(NonNull::from(&self).cast(), DynTypeId::of::<()>(), size_of::<()>());
}
fn is_dynamic(&self) -> bool {
false
}
}
impl<C: Component> Bundle for C { impl<C: Component> Bundle for C {
fn type_ids(&self) -> Vec<DynTypeId> { fn type_ids(&self) -> Vec<DynTypeId> {
vec![DynTypeId::of::<C>()] vec![DynTypeId::of::<C>()]

View File

@ -32,7 +32,7 @@ impl From<&Variant> for VariantType {
/// Generates the following different outputs: /// Generates the following different outputs:
/// ///
/// ```compile_fail /// ```nobuild
/// // for struct variants /// // for struct variants
/// TestEnum::Error { msg, code } /// TestEnum::Error { msg, code }
/// ///
@ -98,7 +98,7 @@ fn gen_variant_if(enum_id: &proc_macro2::Ident, variant: &Variant, if_body: proc
/// Generates the following: /// Generates the following:
/// ///
/// ```compile_fail /// ```nobuild
/// /// generated one field here /// /// generated one field here
/// if name == "msg" { /// if name == "msg" {
/// return Some(msg); /// return Some(msg);
@ -129,7 +129,7 @@ fn gen_if_field_names(variant: &Variant) -> proc_macro2::TokenStream {
/// Generates the following rust code: /// Generates the following rust code:
/// ///
/// ```compile_fail /// ```nobuild
/// match name { /// match name {
/// "msg" | "code" => true, /// "msg" | "code" => true,
/// _ => false, /// _ => false,
@ -153,7 +153,7 @@ fn gen_match_names(variant: &Variant) -> proc_macro2::TokenStream {
/// Generates the following: /// Generates the following:
/// ///
/// ```compile_fail /// ```nobuild
/// /// generated one field here /// /// generated one field here
/// if idx == 0 { /// if idx == 0 {
/// return Some(a); /// return Some(a);
@ -190,7 +190,7 @@ fn gen_if_field_indices(variant: &Variant) -> proc_macro2::TokenStream {
/// Generates the following: /// Generates the following:
/// ///
/// ```compile_fail /// ```nobuild
/// /// generated one field here /// /// generated one field here
/// if idx == 0 { /// if idx == 0 {
/// return Some("a"); /// return Some("a");
@ -226,7 +226,7 @@ fn gen_if_field_indices_names(variant: &Variant) -> proc_macro2::TokenStream {
} }
/// Generates the following: /// Generates the following:
/// ```compile_fail /// ```nobuild
/// /// when `by_index` is false: /// /// when `by_index` is false:
/// ///
/// if let TestEnum::Error{ msg, code} = self { /// if let TestEnum::Error{ msg, code} = self {
@ -300,7 +300,7 @@ fn gen_enum_if_stmts(enum_id: &proc_macro2::Ident, data: &DataEnum, by_index: bo
/// Generates the following rust code: /// Generates the following rust code:
/// ///
/// ```compile_fail /// ```nobuild
/// if let TestEnum::Error { msg, code } = self { /// if let TestEnum::Error { msg, code } = self {
/// return match name { /// return match name {
/// // expands for continuing struct fields /// // expands for continuing struct fields
@ -331,7 +331,7 @@ fn gen_enum_has_field(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_mac
/// Generates the following code: /// Generates the following code:
/// ///
/// ```compile_fail /// ```nobuild
/// match self { /// match self {
/// TestEnum::Start => 0, /// TestEnum::Start => 0,
/// TestEnum::Middle(a, b) => 2, /// TestEnum::Middle(a, b) => 2,
@ -358,7 +358,7 @@ fn gen_enum_fields_len(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_ma
/// Generates the following code: /// Generates the following code:
/// ///
/// ```compile_fail /// ```nobuild
/// if let TestEnum::Error { msg, code } = self { /// if let TestEnum::Error { msg, code } = self {
/// if idx == 0 { /// if idx == 0 {
/// return Some("msg"); /// return Some("msg");
@ -389,7 +389,7 @@ fn gen_enum_field_name_at(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc
} }
/// Generates the following code: /// Generates the following code:
/// ```compile_fail /// ```nobuild
/// match self { /// match self {
/// TestEnum::Start => 0, /// TestEnum::Start => 0,
/// TestEnum::Middle(a, b) => 1, /// TestEnum::Middle(a, b) => 1,
@ -427,7 +427,7 @@ fn gen_enum_variant_name(enum_id: &proc_macro2::Ident, data: &DataEnum, gen_inde
/// Generates a match statement that returns the types of the variants of the enum. /// Generates a match statement that returns the types of the variants of the enum.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match self { /// match self {
/// TestEnum::Start => EnumType::Unit, /// TestEnum::Start => EnumType::Unit,
/// TestEnum::Middle(a, b) => EnumType::Tuple, /// TestEnum::Middle(a, b) => EnumType::Tuple,

View File

@ -28,7 +28,7 @@ impl StructType {
/// contains a borrow (mutable borrow if `is_mut` is true) to the matching struct field. /// contains a borrow (mutable borrow if `is_mut` is true) to the matching struct field.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// // when `is_mut` = false /// // when `is_mut` = false
/// match name { /// match name {
/// "x" => Some(&self.x), /// "x" => Some(&self.x),
@ -85,7 +85,7 @@ fn gen_struct_field_match(data: &DataStruct, is_mut: bool) -> proc_macro2::Token
/// with the provided `val`. /// with the provided `val`.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match name { /// match name {
/// "x" => self.x = any_val.downcast_ref::<f32>() /// "x" => self.x = any_val.downcast_ref::<f32>()
/// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name())) /// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name()))
@ -140,7 +140,7 @@ fn gen_struct_set_field_match(data: &DataStruct) -> proc_macro2::TokenStream {
/// the type of the field. /// the type of the field.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match name { /// match name {
/// "x" => Some("f32"), /// "x" => Some("f32"),
/// "y" => Some("f32"), /// "y" => Some("f32"),
@ -177,7 +177,7 @@ fn gen_struct_field_name_match(data: &DataStruct) -> proc_macro2::TokenStream {
/// with the provided `val`. /// with the provided `val`.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match name { /// match name {
/// 0 => self.x = any_val.downcast_ref::<f32>() /// 0 => self.x = any_val.downcast_ref::<f32>()
/// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name())) /// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name()))
@ -243,7 +243,7 @@ fn gen_struct_set_field_match_idx(data: &DataStruct) -> proc_macro2::TokenStream
/// type of the field. /// type of the field.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match name { /// match name {
/// 0 => Some("f32"), /// 0 => Some("f32"),
/// 1 => Some("f32"), /// 1 => Some("f32"),
@ -274,7 +274,7 @@ fn gen_struct_field_name_match_idx(data: &DataStruct) -> proc_macro2::TokenStrea
/// to the matching struct field. /// to the matching struct field.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// // when `is_mut` = false /// // when `is_mut` = false
/// match idx { /// match idx {
/// 0 => Some(&self.x), /// 0 => Some(&self.x),
@ -335,7 +335,7 @@ fn gen_struct_field_match_idx(data: &DataStruct, is_mut: bool) -> proc_macro2::T
/// and returns an Option that contains the name of the field. /// and returns an Option that contains the name of the field.
/// ///
/// Example: /// Example:
/// ```compile_fail /// ```nobuild
/// match idx { /// match idx {
/// 0 => Some("x"), /// 0 => Some("x"),
/// 1 => Some("y"), /// 1 => Some("y"),

View File

@ -19,6 +19,7 @@ in
extensions = [ extensions = [
"rust-src" "rust-src"
"rust-analysis" "rust-analysis"
"miri-preview"
]; ];
}) })
]; ];