diff --git a/core/entity.jai b/core/entity.jai index 019cddf..4139808 100644 --- a/core/entity.jai +++ b/core/entity.jai @@ -53,7 +53,7 @@ Renderable :: struct { MAX_CHILDREN :: 16; Entity :: struct { - id: Entity_Id; + id: Entity_Id; @Hide type : Type; enabled: bool = true; diff --git a/core/scene.jai b/core/scene.jai index 5758948..3f97896 100644 --- a/core/scene.jai +++ b/core/scene.jai @@ -263,7 +263,7 @@ update_entity_transform :: (e: *Entity, parent_matrix: Matrix4 = Matrix4_Identit } } -get_entity_with_id :: (scene: *Scene, id: s64) -> *Entity { +get_entity_by_id :: (scene: *Scene, id: s64) -> *Entity { for scene.entities { if it.id == id return it; } diff --git a/metaprogram.jai b/metaprogram.jai index 3c45a3a..1c52352 100644 --- a/metaprogram.jai +++ b/metaprogram.jai @@ -129,7 +129,15 @@ generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path: new_path = tprint("%1.%2", path, it.name); } - if it.type.type == { + type : Type_Info_Tag; + if it.type.type == .VARIANT { + info_variant := cast(*Type_Info_Variant)it.type; + type = info_variant.variant_of.type; + } else { + type = it.type.type; + } + + if type == { case .STRUCT; { info_struct := cast(*Type_Info_Struct) it.type; if info_struct.name == "Quaternion" { @@ -151,7 +159,7 @@ generate_member_ui :: (type: *Type_Info_Struct, builder: *String_Builder, path: } //case .ENUM; #through; case .INTEGER; { - print_to_builder(builder, "\tui_int_field(tprint(\"%\"), *e.%);\n", new_path, new_path); + print_to_builder(builder, "\tui_int_field(tprint(\"%\"), cast(*int)*e.%);\n", new_path, new_path); } } } @@ -168,7 +176,15 @@ generate_member_serialization :: (type: *Type_Info_Struct, builder: *String_Buil new_path = tprint("%1.%2", path, it.name); } - if it.type.type == { + type : Type_Info_Tag; + if it.type.type == .VARIANT { + info_variant := cast(*Type_Info_Variant)it.type; + type = info_variant.variant_of.type; + } else { + type = it.type.type; + } + + if type == { case .STRUCT; { info_struct := cast(*Type_Info_Struct) it.type; generate_member_serialization(info_struct, builder, new_path); @@ -196,7 +212,16 @@ generate_member_deserialization :: (type: *Type_Info_Struct, builder: *String_Bu } else { new_path = tprint("%1.%2", path, it.name); } - if it.type.type == { + + type : Type_Info_Tag; + if it.type.type == .VARIANT { + info_variant := cast(*Type_Info_Variant)it.type; + type = info_variant.variant_of.type; + } else { + type = it.type.type; + } + + if type == { case .STRUCT; { info_struct := cast(*Type_Info_Struct) it.type; generate_member_deserialization(info_struct, builder, new_path); @@ -207,11 +232,14 @@ generate_member_deserialization :: (type: *Type_Info_Struct, builder: *String_Bu } case .BOOL; #through; case .FLOAT; #through; - case .ENUM; #through; - case .INTEGER; { + case .ENUM; { print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path); print_to_builder(builder, "\t\t\t\t\tscan2(values[1], \"\%\", *e.%);\n", new_path); } + case .INTEGER; { + print_to_builder(builder, "\t\t\t\tcase \"%\";\n", new_path); + print_to_builder(builder, "\t\t\t\t\tscan2(values[1], \"\%\", cast(*int)*e.%);\n", new_path); + } } } } @@ -227,7 +255,15 @@ generate_member_copy :: (type: *Type_Info_Struct, builder: *String_Builder, path new_path = tprint("%1.%2", path, it.name); } - if it.type.type == { + type : Type_Info_Tag; + if it.type.type == .VARIANT { + info_variant := cast(*Type_Info_Variant)it.type; + type = info_variant.variant_of.type; + } else { + type = it.type.type; + } + + if type == { case .STRUCT; { info_struct := cast(*Type_Info_Struct) it.type; generate_member_copy(info_struct, builder, new_path);