From 1afe4876cb8133c5b47fdcfeb07decc5565c4844 Mon Sep 17 00:00:00 2001 From: Omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:59:35 +1100 Subject: wip: transform propagation --- examples/transforms/ex_transforms.c | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 examples/transforms/ex_transforms.c (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c new file mode 100644 index 0000000..edb1c21 --- /dev/null +++ b/examples/transforms/ex_transforms.c @@ -0,0 +1,51 @@ +#include + +#include "core.h" +#include "render.h" +#include "render_types.h" +#include "maths_types.h" +#include "maths.h" +#include "transform_hierarchy.h" + +int main() { + core* core = core_bringup(); + + // Set up scene + vec3 camera_pos = vec3(3., 4., 10.); + vec3 camera_front = vec3_normalise(vec3_negate(camera_pos)); + camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0)); + + model_handle cube_handle = + model_load_obj(core, "assets/models/obj/cube/cube.obj", true); + model* cube = &core->models->data[cube_handle.raw]; + // 2. upload vertex data to gpu + model_upload_meshes(&core->renderer, cube); + + // Create transform hierarchy + transform_hierarchy* transform_tree = transform_hierarchy_create(); + transform_node* root_node = transform_hierarchy_root_node(transform_tree); + + // Add nodes + // -- 4 cubes + transform cube1 = transform_create(vec3(-2.0, -2.0, -2.0), quat_ident(), 2.0); + transform cube2 = transform_create(vec3(2.0, 2.0, 2.0), quat_ident(), 2.0); + transform_hierarchy_add_node(root_node, cube_handle, cube1); + transform_hierarchy_add_node(root_node, cube_handle, cube2); + + + // Main loop + while (!glfwWindowShouldClose(core->renderer.window)) { + input_update(&core->input); + threadpool_process_results(&core->threadpool, 1); + + render_frame_begin(&core->renderer); + + // insert work here + + render_frame_end(&core->renderer); + } + + transform_hierarchy_free(transform_tree); + + return 0; +} -- cgit v1.2.3-70-g09d2 From cbcd40391c445afb836217a64e0bd96bc54cb805 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:39:40 +1100 Subject: rendering using transforms --- examples/transforms/ex_transforms.c | 49 +++++++++++++++++++++++++++++++------ src/maths/maths.h | 2 +- src/renderer/render.c | 16 ++++++------ src/renderer/render.h | 4 +-- src/transform_hierarchy.c | 43 +++++++++++++++++++++++--------- src/transform_hierarchy.h | 4 +-- 6 files changed, 86 insertions(+), 32 deletions(-) (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c index edb1c21..b11fbc7 100644 --- a/examples/transforms/ex_transforms.c +++ b/examples/transforms/ex_transforms.c @@ -7,6 +7,14 @@ #include "maths.h" #include "transform_hierarchy.h" +const vec3 pointlight_positions[4] = { + { 0.7, 0.2, 2.0 }, + { 2.3, -3.3, -4.0 }, + { -4.0, 2.0, -12.0 }, + { 0.0, 0.0, -3.0 }, +}; +point_light point_lights[4]; + int main() { core* core = core_bringup(); @@ -18,20 +26,43 @@ int main() { model_handle cube_handle = model_load_obj(core, "assets/models/obj/cube/cube.obj", true); model* cube = &core->models->data[cube_handle.raw]; - // 2. upload vertex data to gpu model_upload_meshes(&core->renderer, cube); + directional_light dir_light = { .direction = (vec3){ -0.2, -1.0, -0.3 }, + .ambient = (vec3){ 0.2, 0.2, 0.2 }, + .diffuse = (vec3){ 0.5, 0.5, 0.5 }, + .specular = (vec3){ 1.0, 1.0, 1.0 } }; + // point lights setup + for (int i = 0; i < 4; i++) { + point_lights[i].position = pointlight_positions[i]; + point_lights[i].ambient = (vec3){ 0.05, 0.05, 0.05 }; + point_lights[i].diffuse = (vec3){ 0.8, 0.8, 0.8 }; + point_lights[i].specular = (vec3){ 1.0, 1.0, 1.0 }; + point_lights[i].constant = 1.0; + point_lights[i].linear = 0.09; + point_lights[i].quadratic = 0.032; + } + + scene our_scene = { .dir_light = dir_light, .n_point_lights = 4 }; + memcpy(&our_scene.point_lights, &point_lights, sizeof(point_light[4])); + // Create transform hierarchy transform_hierarchy* transform_tree = transform_hierarchy_create(); transform_node* root_node = transform_hierarchy_root_node(transform_tree); - // Add nodes // -- 4 cubes - transform cube1 = transform_create(vec3(-2.0, -2.0, -2.0), quat_ident(), 2.0); - transform cube2 = transform_create(vec3(2.0, 2.0, 2.0), quat_ident(), 2.0); - transform_hierarchy_add_node(root_node, cube_handle, cube1); - transform_hierarchy_add_node(root_node, cube_handle, cube2); + transform cube1 = transform_create(vec3(1.0, 1.0, 0.0), quat_ident(), 2.0); + transform cube2 = transform_create(vec3(1.0, -1.0, 0.0), quat_ident(), 2.0); + transform cube3 = transform_create(vec3(0.0, 1.0, 0.0), quat_ident(), 2.0); + transform cube4 = transform_create(vec3(0.0, -1.0, 0.0), quat_ident(), 2.0); + transform_node* node1 = transform_hierarchy_add_node(root_node, cube_handle, cube1); + transform_node* node2 = transform_hierarchy_add_node(root_node, cube_handle, cube2); + + transform_node* node3 = transform_hierarchy_add_node(node1, cube_handle, cube3); + transform_node* node4 = transform_hierarchy_add_node(node2, cube_handle, cube4); + transform_hierarchy_debug_print(root_node, core); + // Main loop while (!glfwWindowShouldClose(core->renderer.window)) { @@ -39,8 +70,12 @@ int main() { threadpool_process_results(&core->threadpool, 1); render_frame_begin(&core->renderer); + transform_hierarchy_propagate_transforms(transform_tree); - // insert work here + draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); + draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); + draw_model(&core->renderer, &cam, cube, &node3->world_matrix_tf, &our_scene); + draw_model(&core->renderer, &cam, cube, &node4->world_matrix_tf, &our_scene); render_frame_end(&core->renderer); } diff --git a/src/maths/maths.h b/src/maths/maths.h index 390b611..6834f69 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -203,7 +203,7 @@ static inline mat4 mat4_look_at(vec3 position, vec3 target, vec3 up) { .is_dirty = false }) static transform transform_create(vec3 pos, quat rot, f32 scale) { - return (transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = false }; + return (transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true }; } static inline mat4 transform_to_mat(transform *tf) { diff --git a/src/renderer/render.c b/src/renderer/render.c index 7884db6..ca625ed 100644 --- a/src/renderer/render.c +++ b/src/renderer/render.c @@ -80,7 +80,7 @@ void default_material_init() { texture_data_upload(&DEFAULT_MATERIAL.specular_texture); } -void draw_model(renderer* ren, camera* camera, model* model, transform tf, scene* scene) { +void draw_model(renderer* ren, camera* camera, model* model, mat4* model_tf, scene* scene) { // TRACE("Drawing model: %s", model->name); mat4 view; mat4 proj; @@ -103,11 +103,11 @@ void draw_model(renderer* ren, camera* camera, model* model, transform tf, scene } // TRACE("Drawing mesh %d", i); material* mat = &model->materials->data[m->material_index]; - draw_mesh(ren, m, tf, mat, &view, &proj); + draw_mesh(ren, m, model_tf, mat, &view, &proj); } } -void draw_mesh(renderer* ren, mesh* mesh, transform tf, material* mat, mat4* view, mat4* proj) { +void draw_mesh(renderer* ren, mesh* mesh, mat4* model_tf, material* mat, mat4* view, mat4* proj) { shader lighting_shader = ren->blinn_phong; // bind buffer @@ -119,12 +119,12 @@ void draw_mesh(renderer* ren, mesh* mesh, transform tf, material* mat, mat4* vie uniform_f32(lighting_shader.program_id, "material.shininess", 32.); // upload model transform - mat4 trans = mat4_translation(tf.position); - mat4 rot = mat4_rotation(tf.rotation); - mat4 scale = mat4_scale(tf.scale); - mat4 model_tf = mat4_mult(trans, mat4_mult(rot, scale)); + // mat4 trans = mat4_translation(tf.position); + // mat4 rot = mat4_rotation(tf.rotation); + // mat4 scale = mat4_scale(tf.scale); + // mat4 model_tf = mat4_mult(trans, mat4_mult(rot, scale)); - uniform_mat4f(lighting_shader.program_id, "model", &model_tf); + uniform_mat4f(lighting_shader.program_id, "model", model_tf); // upload view & projection matrices uniform_mat4f(lighting_shader.program_id, "view", view); uniform_mat4f(lighting_shader.program_id, "projection", proj); diff --git a/src/renderer/render.h b/src/renderer/render.h index 10702e3..61dda75 100644 --- a/src/renderer/render.h +++ b/src/renderer/render.h @@ -17,8 +17,8 @@ void render_frame_end(renderer* ren); // --- models meshes void model_upload_meshes(renderer* ren, model* model); -void draw_model(renderer* ren, camera* camera, model* model, transform tf, scene* scene); -void draw_mesh(renderer* ren, mesh* mesh, transform tf, material* mat, mat4* view, mat4* proj); +void draw_model(renderer* ren, camera* camera, model* model, mat4* tf, scene* scene); +void draw_mesh(renderer* ren, mesh* mesh, mat4* tf, material* mat, mat4* view, mat4* proj); // --- texture texture_data_load(const char* path, bool invert_y); // #frontend diff --git a/src/transform_hierarchy.c b/src/transform_hierarchy.c index 65d4edf..a8b3df1 100644 --- a/src/transform_hierarchy.c +++ b/src/transform_hierarchy.c @@ -18,7 +18,7 @@ struct transform_hierarchy { }; transform_hierarchy* transform_hierarchy_create() { - transform_hierarchy* tfh = malloc(sizeof(transform_hierarchy)); + transform_hierarchy* tfh = malloc(sizeof(struct transform_hierarchy)); tfh->root = (transform_node){ .model = { ABSENT_MODEL_HANDLE }, .tf = TRANSFORM_DEFAULT, @@ -28,7 +28,6 @@ transform_hierarchy* transform_hierarchy_create() { .children = { 0 }, .n_children = 0, .tfh = tfh }; - return tfh; } @@ -51,10 +50,10 @@ void transform_hierarchy_free(transform_hierarchy* tfh) { transform_node* transform_hierarchy_root_node(transform_hierarchy* tfh) { return &tfh->root; } -void transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf) { +transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf) { if (!parent) { WARN("You tried to add a node to a bad parent (NULL?)"); - return; + return NULL; } transform_node* node = malloc(sizeof(transform_node)); node->model = model; @@ -75,6 +74,8 @@ void transform_hierarchy_add_node(transform_node* parent, model_handle model, tr parent->children[next_index] = node; parent->n_children++; } + + return node; } void transform_hierarchy_delete_node(transform_node* node) { @@ -124,7 +125,7 @@ void transform_hierarchy_dfs(transform_node* start_node, bool update_matrix(transform_node* node, void* _ctx_data) { if (!node) return true; // leaf node - if (node->parent->tf.is_dirty) { + if (node->parent && node->parent->tf.is_dirty) { node->tf.is_dirty = true; } @@ -147,17 +148,35 @@ void transform_hierarchy_propagate_transforms(transform_hierarchy* tfh) { transform_hierarchy_dfs(&tfh->root, update_matrix, false, NULL); } -void print_node(transform_node* node, void* _ctx_data) { - // Grab the model - model m = core->models->data[start_node->model.raw]; - printf("Node %s\n", m.name.buf); -} - struct print_ctx { core* core; u32 indentation_lvl; }; -void transform_hierarchy_debug_print(transform_node* start_node, core* core) { +bool print_node(transform_node* node, void* ctx_data) { + struct print_ctx* ctx = (struct print_ctx*)ctx_data; + + if (!node) return true; + if (!node->parent) { + printf("Root Node\n"); + ctx->indentation_lvl++; + return true; + } + + // Grab the model + model m = ctx->core->models->data[node->model.raw]; + for (int i = 0; i < ctx->indentation_lvl; i++) { + printf(" "); + } + printf("Node %s\n", m.name.buf); + ctx->indentation_lvl++; + return true; +} + +void transform_hierarchy_debug_print(transform_node* start_node, core* core) { + struct print_ctx* ctx = malloc(sizeof(struct print_ctx)); + ctx->core = core; + ctx->indentation_lvl = 0; + transform_hierarchy_dfs(start_node, print_node, true, (void*)ctx); } \ No newline at end of file diff --git a/src/transform_hierarchy.h b/src/transform_hierarchy.h index 61989f1..9598fe9 100644 --- a/src/transform_hierarchy.h +++ b/src/transform_hierarchy.h @@ -45,7 +45,7 @@ void transform_hierarchy_propagate_transforms(transform_hierarchy* tfh); transform_node* transform_hierarchy_root_node(transform_hierarchy* tfh); // --- Mutations -void transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf); +transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf); void transform_hierarchy_delete_node(transform_node* node); // --- Traversal @@ -65,4 +65,4 @@ void transform_hierarchy_delete_node(transform_node* node); void transform_hierarchy_dfs(transform_node* start_node, bool (*visit_node)(transform_node* node, void* ctx_data), bool is_pre_order, void* ctx_data); struct core; -void transform_hierarchy_debug_print(transform_node* start_nod, struct core* core); \ No newline at end of file +void transform_hierarchy_debug_print(transform_node* start_node, struct core* core); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 8c331ac497d6e6705cde5e292538d4ab7d9a16ec Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:52:56 +1100 Subject: MOVE --- examples/transforms/ex_transforms.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c index b11fbc7..a3bede7 100644 --- a/examples/transforms/ex_transforms.c +++ b/examples/transforms/ex_transforms.c @@ -51,18 +51,16 @@ int main() { transform_node* root_node = transform_hierarchy_root_node(transform_tree); // Add nodes // -- 4 cubes - transform cube1 = transform_create(vec3(1.0, 1.0, 0.0), quat_ident(), 2.0); - transform cube2 = transform_create(vec3(1.0, -1.0, 0.0), quat_ident(), 2.0); - transform cube3 = transform_create(vec3(0.0, 1.0, 0.0), quat_ident(), 2.0); - transform cube4 = transform_create(vec3(0.0, -1.0, 0.0), quat_ident(), 2.0); + transform cube1 = transform_create(vec3(0.0, -2.0, 0.0), quat_ident(), 0.8); + transform cube2 = transform_create(vec3(0.0, 1.0, 0.0), quat_ident(), 1.0); + transform cube3 = transform_create(vec3(0.0, 1.0, 0.0), quat_ident(), 1.0); + transform cube4 = transform_create(vec3(0.0, 1.0, 0.0), quat_ident(), 1.0); transform_node* node1 = transform_hierarchy_add_node(root_node, cube_handle, cube1); - transform_node* node2 = transform_hierarchy_add_node(root_node, cube_handle, cube2); - - transform_node* node3 = transform_hierarchy_add_node(node1, cube_handle, cube3); - transform_node* node4 = transform_hierarchy_add_node(node2, cube_handle, cube4); + transform_node* node2 = transform_hierarchy_add_node(node1, cube_handle, cube2); + transform_node* node3 = transform_hierarchy_add_node(node2, cube_handle, cube3); + transform_node* node4 = transform_hierarchy_add_node(node3, cube_handle, cube4); transform_hierarchy_debug_print(root_node, core); - // Main loop while (!glfwWindowShouldClose(core->renderer.window)) { @@ -72,6 +70,8 @@ int main() { render_frame_begin(&core->renderer); transform_hierarchy_propagate_transforms(transform_tree); + node1->tf.position.x += 0.002; + node1->tf.is_dirty = true; draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); draw_model(&core->renderer, &cam, cube, &node3->world_matrix_tf, &our_scene); -- cgit v1.2.3-70-g09d2 From 23432fa4b1e4503f6ce7264f1a64fbb9bb42ac3d Mon Sep 17 00:00:00 2001 From: Omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:03:20 +1100 Subject: comment --- examples/transforms/ex_transforms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c index a3bede7..ccb9a6a 100644 --- a/examples/transforms/ex_transforms.c +++ b/examples/transforms/ex_transforms.c @@ -70,7 +70,8 @@ int main() { render_frame_begin(&core->renderer); transform_hierarchy_propagate_transforms(transform_tree); - node1->tf.position.x += 0.002; + // TODO: Add setters to transform API + node1->tf.position.x += 0.004; node1->tf.is_dirty = true; draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); -- cgit v1.2.3-70-g09d2 From 9ef22d2af0001bbc402454c8d605339ec6a428ae Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:03:33 +1100 Subject: draw_scene that uses transform hierarchy to draw all models --- examples/transforms/ex_transforms.c | 21 +++++++++++++-------- src/renderer/render.c | 27 +++++++++++++++++++++++++++ src/renderer/render.h | 2 ++ src/transform_hierarchy.c | 9 +++++---- 4 files changed, 47 insertions(+), 12 deletions(-) (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c index a3bede7..0f1752d 100644 --- a/examples/transforms/ex_transforms.c +++ b/examples/transforms/ex_transforms.c @@ -1,10 +1,11 @@ #include #include "core.h" +#include "maths.h" +#include "maths_types.h" +#include "mem.h" #include "render.h" #include "render_types.h" -#include "maths_types.h" -#include "maths.h" #include "transform_hierarchy.h" const vec3 pointlight_positions[4] = { @@ -23,8 +24,7 @@ int main() { vec3 camera_front = vec3_normalise(vec3_negate(camera_pos)); camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0)); - model_handle cube_handle = - model_load_obj(core, "assets/models/obj/cube/cube.obj", true); + model_handle cube_handle = model_load_obj(core, "assets/models/obj/cube/cube.obj", true); model* cube = &core->models->data[cube_handle.raw]; model_upload_meshes(&core->renderer, cube); @@ -62,6 +62,9 @@ int main() { transform_hierarchy_debug_print(root_node, core); + char* frame_allocator_storage = malloc(1024 * 1024 * 64); + arena frame_arena = arena_create(frame_allocator_storage, 1024 * 1024 * 64); + // Main loop while (!glfwWindowShouldClose(core->renderer.window)) { input_update(&core->input); @@ -72,12 +75,14 @@ int main() { node1->tf.position.x += 0.002; node1->tf.is_dirty = true; - draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); - draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); - draw_model(&core->renderer, &cam, cube, &node3->world_matrix_tf, &our_scene); - draw_model(&core->renderer, &cam, cube, &node4->world_matrix_tf, &our_scene); + draw_scene(&frame_arena, core->models, &core->renderer, &cam, transform_tree, &our_scene); + // draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); + // draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); + // draw_model(&core->renderer, &cam, cube, &node3->world_matrix_tf, &our_scene); + // draw_model(&core->renderer, &cam, cube, &node4->world_matrix_tf, &our_scene); render_frame_end(&core->renderer); + arena_free_all(&frame_arena); } transform_hierarchy_free(transform_tree); diff --git a/src/renderer/render.c b/src/renderer/render.c index ca625ed..043a1fc 100644 --- a/src/renderer/render.c +++ b/src/renderer/render.c @@ -1,3 +1,6 @@ +#include +#include "mem.h" +#include "transform_hierarchy.h" #define STB_IMAGE_IMPLEMENTATION #include @@ -80,6 +83,30 @@ void default_material_init() { texture_data_upload(&DEFAULT_MATERIAL.specular_texture); } +typedef struct draw_ctx { + model_darray* models; + renderer* ren; + camera* cam; + scene* scene; +} draw_ctx; +bool draw_scene_node(transform_node* node, void* ctx_data) { + if (!node || !node->parent) return true; + draw_ctx* ctx = ctx_data; + model* m = &ctx->models->data[node->model.raw]; + draw_model(ctx->ren, ctx->cam, m, &node->world_matrix_tf, ctx->scene); + return true; +} + +void draw_scene(arena* frame, model_darray* models, renderer* ren, camera* camera, + transform_hierarchy* tfh, scene* scene) { + draw_ctx* ctx = arena_alloc(frame, sizeof(draw_ctx)); + ctx->models = models; + ctx->ren = ren; + ctx->cam = camera; + ctx->scene = scene; + transform_hierarchy_dfs(transform_hierarchy_root_node(tfh), draw_scene_node, true, ctx); +} + void draw_model(renderer* ren, camera* camera, model* model, mat4* model_tf, scene* scene) { // TRACE("Drawing model: %s", model->name); mat4 view; diff --git a/src/renderer/render.h b/src/renderer/render.h index 61dda75..bcdeb78 100644 --- a/src/renderer/render.h +++ b/src/renderer/render.h @@ -3,6 +3,7 @@ #include "camera.h" #include "loaders.h" #include "render_types.h" +#include "transform_hierarchy.h" // --- Lifecycle /** @brief initialise the render system frontend */ @@ -19,6 +20,7 @@ void render_frame_end(renderer* ren); void model_upload_meshes(renderer* ren, model* model); void draw_model(renderer* ren, camera* camera, model* model, mat4* tf, scene* scene); void draw_mesh(renderer* ren, mesh* mesh, mat4* tf, material* mat, mat4* view, mat4* proj); +void draw_scene(arena* frame, model_darray* models, renderer* ren, camera* camera, transform_hierarchy *tfh, scene* scene); // --- texture texture_data_load(const char* path, bool invert_y); // #frontend diff --git a/src/transform_hierarchy.c b/src/transform_hierarchy.c index a8b3df1..a36b8ef 100644 --- a/src/transform_hierarchy.c +++ b/src/transform_hierarchy.c @@ -7,11 +7,11 @@ #include #include +#include "core.h" #include "log.h" #include "maths.h" #include "maths_types.h" #include "render_types.h" -#include "core.h" struct transform_hierarchy { transform_node root; @@ -50,7 +50,8 @@ void transform_hierarchy_free(transform_hierarchy* tfh) { transform_node* transform_hierarchy_root_node(transform_hierarchy* tfh) { return &tfh->root; } -transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf) { +transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model, + transform tf) { if (!parent) { WARN("You tried to add a node to a bad parent (NULL?)"); return NULL; @@ -163,14 +164,14 @@ bool print_node(transform_node* node, void* ctx_data) { return true; } - // Grab the model + // Grab the model model m = ctx->core->models->data[node->model.raw]; for (int i = 0; i < ctx->indentation_lvl; i++) { printf(" "); } printf("Node %s\n", m.name.buf); ctx->indentation_lvl++; - + return true; } -- cgit v1.2.3-70-g09d2 From 013e1c111e0717f6dc01a8e8582e13a4095e05bc Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:53:06 +1100 Subject: remove commented individual draw_model calls --- examples/transforms/ex_transforms.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'examples/transforms') diff --git a/examples/transforms/ex_transforms.c b/examples/transforms/ex_transforms.c index 383454e..689c49d 100644 --- a/examples/transforms/ex_transforms.c +++ b/examples/transforms/ex_transforms.c @@ -77,10 +77,6 @@ int main() { node1->tf.position.x += 0.004; node1->tf.is_dirty = true; draw_scene(&frame_arena, core->models, &core->renderer, &cam, transform_tree, &our_scene); - // draw_model(&core->renderer, &cam, cube, &node1->world_matrix_tf, &our_scene); - // draw_model(&core->renderer, &cam, cube, &node2->world_matrix_tf, &our_scene); - // draw_model(&core->renderer, &cam, cube, &node3->world_matrix_tf, &our_scene); - // draw_model(&core->renderer, &cam, cube, &node4->world_matrix_tf, &our_scene); render_frame_end(&core->renderer); arena_free_all(&frame_arena); -- cgit v1.2.3-70-g09d2