writing scene

This commit is contained in:
Luka Jankovic 2025-07-26 01:17:13 +02:00
parent 0be3768867
commit fe34c61b12
3 changed files with 17 additions and 8 deletions

View file

@ -47,10 +47,11 @@ void kubo_file_write(struct kubo_context *context) {
struct kubo_file_scene *scene = malloc(sizeof(struct kubo_file_scene));
scene->walls_count = context->walls.count;
scene->walls = malloc(sizeof(struct kubo_file_wall) * scene->walls_count);
scene->walls = malloc(sizeof(struct kubo_file_wall) * context->walls.count);
for (size_t i = 0; i < scene->walls_count; i++) {
struct kubo_wall *wall = kubo_wall_arr_get(&context->walls, i);
scene->walls[i].vertices_count = wall->vertices.count;
scene->walls[i].vertices =
malloc(sizeof(kubo_file_vertex) * wall->vertices.count);
for (size_t j = 0; j < wall->vertices.count; j++) {
@ -66,4 +67,10 @@ void kubo_file_write(struct kubo_context *context) {
if (err != CYAML_OK) {
printf("Error writing yaml file %s\n", context->file_name);
}
for (size_t i = 0; i < scene->walls_count; i++) {
free(scene->walls[i].vertices);
}
free(scene);
}