Debug visualize tris of static tlas
This commit is contained in:
parent
7da986970e
commit
bb6498a193
BIN
assets/blender/test_level_blend/NurbsPath.glb
(Stored with Git LFS)
BIN
assets/blender/test_level_blend/NurbsPath.glb
(Stored with Git LFS)
Binary file not shown.
@ -40,6 +40,6 @@
|
||||
:scale (1.000000 1.000000 1.000000))
|
||||
(inst
|
||||
:model "assets/blender/test_level_blend/NurbsPath.glb"
|
||||
:pos (0.000000 0.000000 0.000000)
|
||||
:pos (0.000000 1.000000 0.000000)
|
||||
:rot (0.000000 0.000000 0.000000 1.000000)
|
||||
:scale (1.000000 1.000000 1.000000))
|
||||
|
@ -512,6 +512,8 @@ get_bvh :: proc(assetman: ^Asset_Manager, path: cstring) -> (Loaded_BVH, bool) {
|
||||
vert_count += int(mesh.vertexCount)
|
||||
indices_count += int(mesh.triangleCount * 3)
|
||||
}
|
||||
assert(vert_count < int(max(u16)))
|
||||
|
||||
vertices := make([]bvh.Vec3, vert_count)
|
||||
indices := make([]u16, indices_count)
|
||||
|
||||
@ -526,7 +528,6 @@ get_bvh :: proc(assetman: ^Asset_Manager, path: cstring) -> (Loaded_BVH, bool) {
|
||||
|
||||
for j in 0 ..< len(mesh_indices) {
|
||||
index := vert_count + int(mesh_indices[j])
|
||||
assert(index <= int(max(u16)))
|
||||
indices[indices_count + j] = u16(index)
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,37 @@ debug_draw_bvh_bounds_mesh :: proc(bvh: ^BVH, mesh: Mesh, pos: rl.Vector3, node_
|
||||
}
|
||||
}
|
||||
|
||||
Iterator :: struct {
|
||||
bvh: ^BVH,
|
||||
nodes_to_process: queue.Queue(i32),
|
||||
}
|
||||
|
||||
iterator :: proc(bvh: ^BVH) -> (it: Iterator) {
|
||||
it.bvh = bvh
|
||||
queue.init(&it.nodes_to_process, queue.DEFAULT_CAPACITY, context.temp_allocator)
|
||||
|
||||
if len(bvh.nodes) > 0 {
|
||||
queue.push_back(&it.nodes_to_process, 0)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
iterator_next :: proc(it: ^Iterator) -> (node: Node, node_index: i32, ok: bool) {
|
||||
if queue.len(it.nodes_to_process) == 0 {
|
||||
return {}, -1, false
|
||||
}
|
||||
|
||||
node_index = queue.pop_front(&it.nodes_to_process)
|
||||
node = it.bvh.nodes[node_index]
|
||||
if !is_leaf_node(node) {
|
||||
left_child := node.child_or_prim_start
|
||||
queue.push_back_elems(&it.nodes_to_process, left_child, left_child + 1)
|
||||
}
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
|
||||
debug_draw_bvh_bounds :: proc(bvh: ^BVH, primitive_bounds: []AABB, node_index: int) {
|
||||
tracy.Zone()
|
||||
|
||||
|
@ -70,6 +70,28 @@ draw_debug_scene :: proc(scene: ^Scene, debug_state: ^Debug_State) {
|
||||
sim_state.static_tlas.level_geom_aabbs,
|
||||
0,
|
||||
)
|
||||
|
||||
it := bvh.iterator(&sim_state.static_tlas.bvh_tree)
|
||||
|
||||
for node in bvh.iterator_next(&it) {
|
||||
if bvh.is_leaf_node(node) {
|
||||
prim_start := node.child_or_prim_start
|
||||
|
||||
for level_geom_idx in prim_start ..< prim_start + node.prim_len {
|
||||
level_geom_handle := index_to_level_geom(int(level_geom_idx))
|
||||
level_geom := get_level_geom(sim_state, level_geom_handle)
|
||||
blas := get_level_geom_blas(sim_state, level_geom_handle)
|
||||
vertices, indices := get_level_geom_data(sim_state, level_geom_handle)
|
||||
|
||||
bvh.debug_draw_bvh_bounds_mesh(
|
||||
&blas,
|
||||
bvh.Mesh{vertices = vertices, indices = indices},
|
||||
level_geom.x,
|
||||
0,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamic TLAS
|
||||
|
BIN
src_assets/test_level.blend
(Stored with Git LFS)
BIN
src_assets/test_level.blend
(Stored with Git LFS)
Binary file not shown.
BIN
src_assets/test_level.blend1
(Stored with Git LFS)
BIN
src_assets/test_level.blend1
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user