i hope your hapy
[carveJwlIkooP6JGAAIwe30JlM.git] / world_volumes.h
1 #ifndef WORLD_VOLUMES_H
2 #define WORLD_VOLUMES_H
3
4 #include "world.h"
5
6 #if 0
7 /*
8 * BVH implementation
9 * ----------------------------------------------------------------------------
10 */
11
12 VG_STATIC void volume_vg_expand_bound( void *user, boxf bound, u32 item_index )
13 {
14 world_instance *world = user;
15
16 ent_volume *volume_array = world_ent_array( world, k_ent_volume ),
17 *volume = volume_array + item_index;
18
19 m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f, 1.0f, 1.0f} );
20 m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f, 1.0f,-1.0f} );
21 m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f,-1.0f, 1.0f} );
22 m4x3_expand_aabb_point( volume->transform, bound, (v3f){ 1.0f,-1.0f,-1.0f} );
23 m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f, 1.0f, 1.0f} );
24 m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f, 1.0f,-1.0f} );
25 m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f,-1.0f, 1.0f} );
26 m4x3_expand_aabb_point( volume->transform, bound, (v3f){-1.0f,-1.0f,-1.0f} );
27 }
28
29 VG_STATIC float volume_vg_centroid( void *user, u32 item_index, int axis )
30 {
31 world_instance *world = user;
32
33 ent_volume *volume_array = world_ent_array( world, k_ent_volume ),
34 *volume = volume_array + item_index;
35
36 return volume->transform[3][axis];
37 }
38
39 VG_STATIC void volume_vg_swap( void *user, u32 ia, u32 ib )
40 {
41 world_instance *world = user;
42 ent_volume *volume_array = world_ent_array( world, k_ent_volume ),
43 *a = volume_array + ia,
44 *b = volume_array + ib,
45 temp;
46
47 temp = *a;
48 *a = *b;
49 *b = temp;
50 }
51
52 VG_STATIC void volume_vg_debug( void *user, u32 item_index )
53 {
54 world_instance *world = user;
55 ent_volume *volume_array = world_ent_array( world, k_ent_volume ),
56 *volume = volume_array + item_index;
57
58 vg_line_boxf_transformed( volume->transform, (boxf){{-1.0f,-1.0f,-1.0f},
59 { 1.0f, 1.0f, 1.0f}},
60 0xff00ff00 );
61 }
62
63 VG_STATIC bh_system bh_system_volumes =
64 {
65 .expand_bound = volume_vg_expand_bound,
66 .item_centroid = volume_vg_centroid,
67 .item_closest = NULL,
68 .item_swap = volume_vg_swap,
69 .item_debug = volume_vg_debug,
70 .cast_ray = NULL
71 };
72 #endif
73
74 #endif /* WORLD_VOLUMES_H */