Scene loading/saving improvements, transform gizmo, entity creation

This commit is contained in:
2024-10-19 19:45:04 +02:00
parent fae8ea7cba
commit 3d98ba0023
15 changed files with 985 additions and 460 deletions

View File

@@ -237,6 +237,40 @@ generate_code :: (w: Workspace) {
entity_storage_string = builder_to_string(*builder);
}
{
builder: String_Builder;
for entity_type_names {
print_to_builder(*builder, "scene.by_type._%1.allocator = scene.allocator;", it);
}
build_string := sprint(INIT_SCENE, builder_to_string(*builder));
add_build_string(build_string, w);
}
{
builder: String_Builder;
for entity_type_names {
lower := to_lower_copy_new(it,, allocator=temp);
print_to_builder(*builder, "if ui_clickable_label(\"New %1\") return new_%2();", it, lower);;
}
build_string := sprint(EDITOR_UI_ENTITY_CREATION, builder_to_string(*builder));
add_build_string(build_string, w);
}
{
builder: String_Builder;
for entity_type_names {
print_to_builder(*builder, "\tcase %1; bucket_array_remove(*e.scene.by_type._%1, e._locator);", it);
}
build_string := sprint(DELETE_ENTITY, builder_to_string(*builder));
add_build_string(build_string, w);
}
{
builder: String_Builder;
@@ -252,12 +286,13 @@ generate_code :: (w: Workspace) {
builder: String_Builder;
for entity_type_names {
print_to_builder(*builder, "\tcase \"%1\"; p, locator := find_and_occupy_empty_slot(*scene.by_type._%1); p._locator = locator; e = p; register_entity(scene, p); init_entity(p); deserialize_entity(scene, lines, cast(*%1)e); update_matrix(*e.transform);\n", it);
print_to_builder(*builder, "\tcase \"%1\"; p, locator := find_and_occupy_empty_slot(*scene.by_type._%1); p._locator = locator; e = p; register_entity(scene, p, id); init_entity(p); deserialize_entity(scene, lines, cast(*%1)e); update_matrix(*e.transform);\n", it);
}
build_string := sprint(DESERIALIZE_ENTITY, builder_to_string(*builder));
add_build_string(build_string, w);
}
{
builder: String_Builder;
@@ -301,6 +336,15 @@ Entity_Storage :: struct {
}
DONE
DELETE_ENTITY :: #string DONE
delete_entity :: (e: *Entity) {
if e.type == {
%1
}
}
DONE
SERIALIZE_ENTITY :: #string DONE
serialize_entity :: (e: *Entity, path: string) {
builder: String_Builder;
@@ -315,7 +359,7 @@ serialize_entity :: (e: *Entity, path: string) {
DONE
DESERIALIZE_ENTITY :: #string DONE
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
deserialize_entity :: (scene: *Scene, id: Entity_Id, path: string) -> *Entity {
content := File.read_entire_file(path);
if content.count == 0 return null;
@@ -335,3 +379,18 @@ deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
return e;
}
DONE
INIT_SCENE :: #string DONE
init_scene :: (scene: *Scene) {
%1
}
DONE
EDITOR_UI_ENTITY_CREATION :: #string DONE
editor_ui_entity_creation :: () -> *Entity {
%1
return null;
}
DONE