Skip to content

Commit

Permalink
lib: Fix missing BVH in some cases
Browse files Browse the repository at this point in the history
I had two booleans for the same thing, so sometimes we started the
renderer without a top-level BVH.
  • Loading branch information
vkoskiv committed Oct 13, 2024
1 parent 70439b4 commit 276d828
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/api/c-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ cr_instance cr_instance_new(struct cr_scene *s_ext, cr_object object, enum cr_ob
default:
return -1;
}
scene->instances_dirty = true;
scene->top_level_dirty = true;
return instance_arr_add(&scene->instances, new);
}

Expand Down Expand Up @@ -367,7 +367,7 @@ void cr_instance_transform(struct cr_scene *s_ext, cr_instance instance, float r
struct matrix4x4 mtx = mtx_convert(row_major);
i->composite.A = mat_mul(i->composite.A, mtx);
i->composite.Ainv = mat_invert(i->composite.A);
scene->instances_dirty = true;
scene->top_level_dirty = true;
}

bool cr_instance_bind_material_set(struct cr_scene *s_ext, cr_instance instance, cr_material_set set) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/renderer/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void renderer_start_interactive(struct renderer *r) {
}

void update_toplevel_bvh(struct world *s) {
if (!s->top_level_dirty) return;
if (!s->top_level_dirty && s->topLevel) return;
struct bvh *new = build_top_level_bvh(s->instances);
//!//!//!//!//!//!//!//!//!//!//!//!
thread_rwlock_wrlock(&s->bvh_lock);
Expand Down Expand Up @@ -480,7 +480,6 @@ struct renderer *renderer_new(void) {

// Move these elsewhere
r->scene = calloc(1, sizeof(*r->scene));
r->scene->instances_dirty = true;
r->scene->asset_path = stringCopy("./");
r->scene->storage.node_pool = newBlock(NULL, 1024);
r->scene->storage.node_table = newHashtable(compareNodes, &r->scene->storage.node_pool);
Expand Down

0 comments on commit 276d828

Please sign in to comment.