X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_volumes.h;h=5bdc2d9ffdc5e52a01fb46536d2e3fde0c1bb012;hb=cb1d2f9fbec8a274aaf7a80c5fb552b928148b1e;hp=f333626087586a752d4aeeeb10e3aa9f3c2ce64e;hpb=a1056ed8198f0f5be0e0f341da8bd49aa6c47198;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_volumes.h b/world_volumes.h index f333626..5bdc2d9 100644 --- a/world_volumes.h +++ b/world_volumes.h @@ -2,65 +2,19 @@ #define WORLD_VOLUMES_H #include "world.h" +#include "bvh.h" -#if 0 -/* - * BVH implementation - * ---------------------------------------------------------------------------- - */ - -VG_STATIC void volume_vg_expand_bound( void *user, boxf bound, u32 item_index ) -{ - world_instance *world = user; - - ent_volume *volume_array = world_ent_array( world, k_ent_volume ), - *volume = volume_array + item_index; - - m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f,-1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( volume->transform, 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_array = world_ent_array( world, k_ent_volume ), - *volume = volume_array + item_index; - - return volume->transform[3][axis]; -} - -VG_STATIC void volume_vg_swap( void *user, u32 ia, u32 ib ) -{ - world_instance *world = user; - ent_volume *volume_array = world_ent_array( world, k_ent_volume ), - *a = volume_array + ia, - *b = volume_array + ib, - temp; - - temp = *a; - *a = *b; - *b = temp; +struct { + int inside; } +static world_volumes; -VG_STATIC void volume_vg_debug( void *user, u32 item_index ) -{ - world_instance *world = user; - ent_volume *volume_array = world_ent_array( world, k_ent_volume ), - *volume = volume_array + item_index; - - vg_line_boxf_transformed( volume->transform, (boxf){{-1.0f,-1.0f,-1.0f}, - { 1.0f, 1.0f, 1.0f}}, - 0xff00ff00 ); -} +VG_STATIC void volume_vg_expand_bound( void *user, boxf bound, u32 item_index ); +VG_STATIC float volume_vg_centroid( void *user, u32 item_index, int axis ); +VG_STATIC void volume_vg_swap( void *user, u32 ia, u32 ib ); +VG_STATIC void volume_vg_debug( void *user, u32 item_index ); -VG_STATIC bh_system bh_system_volumes = +static bh_system bh_system_volumes = { .expand_bound = volume_vg_expand_bound, .item_centroid = volume_vg_centroid, @@ -69,6 +23,5 @@ VG_STATIC bh_system bh_system_volumes = .item_debug = volume_vg_debug, .cast_ray = NULL }; -#endif #endif /* WORLD_VOLUMES_H */