X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_volumes.h;h=2d84e9e00ac8f2f2454a095f97f52a7e203ce7d1;hb=bececcbb7b2e886e72425e7c070e1fdc3aa126dc;hp=da39d265644848fd93989ae3ecbac8f9b78cfec5;hpb=4b8aac300ee193cfa12011dfe0238cfe7d7ffce7;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_volumes.h b/world_volumes.h index da39d26..2d84e9e 100644 --- a/world_volumes.h +++ b/world_volumes.h @@ -1,65 +1,5 @@ -#ifndef WORLD_VOLUMES_H -#define WORLD_VOLUMES_H - +#pragma once #include "world.h" +#include "vg/vg_bvh.h" -/* - * BVH implementation - * ---------------------------------------------------------------------------- - */ - -VG_STATIC void volume_vg_expand_bound( void *user, boxf bound, u32 item_index ) -{ - world_instance *world = user; - - ent_volume *volume = mdl_arritm( &world->ent_volume, item_index ); - - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){ 1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){ 1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){ 1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){ 1.0f,-1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){-1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){-1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){-1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->to_world, bound, (v3f){-1.0f,-1.0f,-1.0f} ); -} - -VG_STATIC float volume_vg_centroid( void *user, u32 item_index, int axis ) -{ - world_instance *world = user; - ent_volume *volume = mdl_arritm( &world->ent_volume, item_index ); - return volume->to_world[3][axis]; -} - -VG_STATIC void volume_vg_swap( void *user, u32 ia, u32 ib ) -{ - world_instance *world = user; - ent_volume *a = mdl_arritm( &world->ent_volume, ia ), - *b = mdl_arritm( &world->ent_volume, ib ), - temp; - - temp = *a; - *a = *b; - *b = temp; -} - -VG_STATIC void volume_vg_debug( void *user, u32 item_index ) -{ - world_instance *world = user; - ent_volume *volume = mdl_arritm( &world->ent_volume, item_index ); - vg_line_boxf_transformed( volume->to_world, (boxf){{-1.0f,-1.0f,-1.0f}, - { 1.0f, 1.0f, 1.0f}}, - 0xff00ff00 ); -} - -VG_STATIC bh_system bh_system_volumes = -{ - .expand_bound = volume_vg_expand_bound, - .item_centroid = volume_vg_centroid, - .item_closest = NULL, - .item_swap = volume_vg_swap, - .item_debug = volume_vg_debug, - .cast_ray = NULL -}; - -#endif /* WORLD_VOLUMES_H */ +void world_volumes_update( world_instance *world, v3f pos );