X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=bvh.h;h=0865ee7d6f0bb16c64a2559c797db7c87d00747c;hb=1d06671f87a9d24596fc6808d8e0db889a818750;hp=1997bedc964dcb30c25fad9c8ffe08ba034c816a;hpb=f014a592925b224f846d8adfc6559539fae1a096;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/bvh.h b/bvh.h index 1997bed..0865ee7 100644 --- a/bvh.h +++ b/bvh.h @@ -210,55 +210,6 @@ VG_STATIC void bh_debug_trace( bh_tree *bh, u32 inode, v3f pos, u32 colour ){ } } -VG_STATIC int bh_ray( bh_tree *bh, v3f co, v3f dir, ray_hit *hit ){ - if( bh->node_count < 2 ) - return 0; - - int count = 0; - u32 stack[100]; - u32 depth = 2; - - stack[0] = 0; - stack[1] = bh->nodes[0].il; - stack[2] = bh->nodes[0].ir; - - v3f dir_inv; - v3_div( (v3f){1.0f,1.0f,1.0f}, dir, dir_inv ); - - while(depth){ - bh_node *inode = &bh->nodes[ stack[depth] ]; - if( ray_aabb1( inode->bbx, co, dir_inv, hit->dist ) ){ - if( inode->count ){ - for( u32 i=0; icount; i++ ){ - u32 idx = inode->start+i; - - if( bh->system->cast_ray ) - count += bh->system->cast_ray( bh->user, idx, co, dir, hit ); - else - count ++; - } - - depth --; - } - else{ - if( depth+1 >= vg_list_size(stack) ){ - vg_error( "Maximum stack reached!\n" ); - return count; - } - - stack[depth] = inode->il; - stack[depth+1] = inode->ir; - depth ++; - } - } - else{ - depth --; - } - } - - return count; -} - typedef struct bh_iter bh_iter; struct bh_iter{ struct {