X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=bvh.h;h=637b55308cc4677140137664be3bf671e12421b3;hb=b9dedb4dd2a1e94ae76a3986716ee3c57e568213;hp=a6a7468b7141f6a7c7f13f8cae11725121840b6d;hpb=a6e1ee0f51aa5570b20aad658365dec896f8c9b8;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/bvh.h b/bvh.h index a6a7468..637b553 100644 --- a/bvh.h +++ b/bvh.h @@ -135,7 +135,7 @@ static void bh_create( bh_tree *bh, bh_system *sys, void *user, u32 item_count ) { bh->system = sys; bh->user = user; - bh->nodes = malloc( sizeof(bh_node) * (item_count*2-1) ); + bh->nodes = vg_alloc( sizeof(bh_node) * (item_count*2-1) ); bh_node *root = &bh->nodes[0]; bh->node_count = 1; @@ -148,8 +148,17 @@ static void bh_create( bh_tree *bh, bh_system *sys, void *user, u32 item_count ) bh_update_bounds( bh, 0 ); bh_subdivide( bh, 0 ); - bh->nodes = realloc( bh->nodes, sizeof(bh_node) * bh->node_count ); + bh->nodes = vg_realloc( bh->nodes, sizeof(bh_node) * bh->node_count ); vg_success( "BVH done, size: %u/%u\n", bh->node_count, (item_count*2-1) ); + +#if 0 + vg_fatal_exit_loop( "Test crash from loader" ); +#endif +} + +static void bh_free( bh_tree *bh ) +{ + vg_free( bh->nodes ); } static void bh_debug_node( bh_tree *bh, u32 inode, v3f pos, u32 colour ) @@ -251,10 +260,7 @@ static int bh_select( bh_tree *bh, boxf box, u32 *buffer, int len ) if( inode->count ) { if( count + inode->count >= len ) - { - vg_error( "Maximum buffer reached!\n" ); return count; - } for( u32 i=0; icount; i++ ) buffer[ count ++ ] = inode->start+i;