X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=bvh.h;h=c18bb3052d9ffa532231ae9bcfcba797dbad4814;hb=a98ce96041b248580c0447bf87d4c6106483cade;hp=27e23b5af516dd0fc8ae809b7c6844400741cf7d;hpb=ecc4dfbfb3adf91d2dfc03ba0ec9a821fcc2390c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/bvh.h b/bvh.h index 27e23b5..c18bb30 100644 --- a/bvh.h +++ b/bvh.h @@ -1,3 +1,7 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #ifndef BVH_H #define BVH_H #include "common.h" @@ -135,7 +139,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 +152,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 )