improve RDM baking
This commit is contained in:
parent
07c41a75fc
commit
e5ca283fdd
@ -252,6 +252,17 @@ draw_tacoma_tab :: (theme: *GR.Overall_Theme, total_r: GR.Rect) {
|
|||||||
if curworld.valid then rdm_bake_all_chunks(curworld.world, tacomaSamples, true);
|
if curworld.valid then rdm_bake_all_chunks(curworld.world, tacomaSamples, true);
|
||||||
}
|
}
|
||||||
r.y += r.h;
|
r.y += r.h;
|
||||||
|
dirty_count := 0;
|
||||||
|
if curworld.valid for chunk: curworld.world.chunks if chunk.rdm_dirty dirty_count += 1;
|
||||||
|
if GR.button(r, tprint("Bake dirty chunks (%)", dirty_count), *t_button_selectable(theme, dirty_count > 0)) {
|
||||||
|
if curworld.valid && dirty_count > 0 {
|
||||||
|
dirty_keys : [..]Chunk_Key;
|
||||||
|
dirty_keys.allocator = temp;
|
||||||
|
for chunk, key: curworld.world.chunks if chunk.rdm_dirty array_add(*dirty_keys, key);
|
||||||
|
rdm_bake_chunks(dirty_keys, curworld.world, tacomaSamples, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r.y += r.h;
|
||||||
if rdm_bake.active {
|
if rdm_bake.active {
|
||||||
total := cast(s32) rdm_bake.jobs.count;
|
total := cast(s32) rdm_bake.jobs.count;
|
||||||
done := rdm_bake.current_job;
|
done := rdm_bake.current_job;
|
||||||
@ -469,6 +480,7 @@ add_trile :: (name: string, x: s32, y: s32, z: s32, orientation: u8 = 0) {
|
|||||||
group.trile_name = sprint("%", name);
|
group.trile_name = sprint("%", name);
|
||||||
array_add(*group.instances, inst);
|
array_add(*group.instances, inst);
|
||||||
array_add(*chunk.groups, group);
|
array_add(*chunk.groups, group);
|
||||||
|
chunk.rdm_dirty = true;
|
||||||
} @Command
|
} @Command
|
||||||
|
|
||||||
remove_trile :: (x: s32, y: s32, z: s32) {
|
remove_trile :: (x: s32, y: s32, z: s32) {
|
||||||
@ -484,6 +496,7 @@ remove_trile :: (x: s32, y: s32, z: s32) {
|
|||||||
for inst, idx: group.instances {
|
for inst, idx: group.instances {
|
||||||
if inst.x == lx && inst.y == ly && inst.z == lz {
|
if inst.x == lx && inst.y == ly && inst.z == lz {
|
||||||
array_unordered_remove_by_index(*group.instances, idx);
|
array_unordered_remove_by_index(*group.instances, idx);
|
||||||
|
chunk.rdm_dirty = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -231,10 +231,10 @@ rdm_bake_start :: (world: World, quality: s32, include_water: bool, chunk_keys:
|
|||||||
// Clean up any previous per-chunk bake data.
|
// Clean up any previous per-chunk bake data.
|
||||||
rdm_cleanup_chunk_bakes();
|
rdm_cleanup_chunk_bakes();
|
||||||
|
|
||||||
// Clean up any previous RDM results stored in chunks.
|
// Clear RDM results only for chunks that are being re-baked.
|
||||||
curworld := get_current_world();
|
curworld := get_current_world();
|
||||||
for *chunk: curworld.world.chunks {
|
for *chunk: curworld.world.chunks {
|
||||||
if chunk.rdm_valid {
|
if chunk.rdm_valid && (bake_all || table_contains(*chunk_key_set, chunk.coord)) {
|
||||||
sg_destroy_image(chunk.rdm_atlas);
|
sg_destroy_image(chunk.rdm_atlas);
|
||||||
sg_destroy_image(chunk.rdm_lookup);
|
sg_destroy_image(chunk.rdm_lookup);
|
||||||
chunk.rdm_valid = false;
|
chunk.rdm_valid = false;
|
||||||
@ -439,6 +439,7 @@ rdm_bake_finish :: () {
|
|||||||
chunk.rdm_atlas = atlas_image;
|
chunk.rdm_atlas = atlas_image;
|
||||||
chunk.rdm_lookup = lookup_image;
|
chunk.rdm_lookup = lookup_image;
|
||||||
chunk.rdm_valid = true;
|
chunk.rdm_valid = true;
|
||||||
|
chunk.rdm_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_entries += cast(s64) bake.entries.count;
|
total_entries += cast(s64) bake.entries.count;
|
||||||
|
|||||||
@ -55,6 +55,7 @@ Chunk :: struct {
|
|||||||
rdm_atlas: sg_image;
|
rdm_atlas: sg_image;
|
||||||
rdm_lookup: sg_image;
|
rdm_lookup: sg_image;
|
||||||
rdm_valid: bool;
|
rdm_valid: bool;
|
||||||
|
rdm_dirty: bool;
|
||||||
rdm_atlas_path: string;
|
rdm_atlas_path: string;
|
||||||
rdm_lookup_path: string;
|
rdm_lookup_path: string;
|
||||||
#if !FLAG_RELEASE_BUILD {
|
#if !FLAG_RELEASE_BUILD {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user