X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=inline;f=world.h;h=9883b295d6916bb06b3466f057301b29cf2fe08e;hb=66b3ec9c538fefd79c2de08e0dcdf070b4331885;hp=ff2c2e3610b4bb79b809bbd1be2e289d641b8d92;hpb=4fa1c611e0af4c32cdcc891f8c511217a2762d65;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index ff2c2e3..9883b29 100644 --- a/world.h +++ b/world.h @@ -731,16 +731,14 @@ VG_STATIC int spherecast_world( world_instance *world, float min_t = 1.0f; int idx; - while( bh_next( world->geo_bh, &it, region, &idx ) ) - { + while( bh_next( world->geo_bh, &it, region, &idx ) ){ u32 *ptri = &world->scene_geo->arrindices[ idx*3 ]; v3f tri[3]; boxf box; box_init_inf( box ); - for( int j=0; j<3; j++ ) - { + for( int j=0; j<3; j++ ){ v3_copy( world->scene_geo->arrvertices[ptri[j]].co, tri[j] ); box_addpt( box, tri[j] ); } @@ -753,10 +751,8 @@ VG_STATIC int spherecast_world( world_instance *world, float t; v3f n1; - if( spherecast_triangle( tri, pa, dir, r, &t, n1 ) ) - { - if( t < min_t ) - { + if( spherecast_triangle( tri, pa, dir, r, &t, n1 ) ){ + if( t < min_t ){ min_t = t; hit = idx; v3_copy( n1, n ); @@ -772,18 +768,16 @@ VG_STATIC struct world_surface *world_tri_index_surface( world_instance *world, u32 index ) { - for( int i=1; isurface_count; i++ ) - { - struct world_surface *mat = &world->surfaces[i]; + for( int i=1; isurface_count; i++ ){ + struct world_surface *surf = &world->surfaces[i]; - if( (index >= mat->sm_geo.vertex_start) && - (index < mat->sm_geo.vertex_start+mat->sm_geo.vertex_count ) ) + if( (index >= surf->sm_geo.vertex_start) && + (index < surf->sm_geo.vertex_start+surf->sm_geo.vertex_count ) ) { - return mat; + return surf; } } - /* error surface */ return &world->surfaces[0]; }