X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=scene.h;h=340207582ba94cfe46d4dd017d178c3f89079e8f;hb=bdac014448b6ec968fe645f1581f321144f07dba;hp=51ce10315c38fdcb47fe84f49eaec103e8445266;hpb=47941822dae18a018c985847b052e70214a3ccc6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/scene.h b/scene.h index 51ce103..3402075 100644 --- a/scene.h +++ b/scene.h @@ -36,8 +36,7 @@ VG_STATIC scene *scene_init( void *lin_alloc, u32 max_verts, u32 max_indices ) pscene->max_vertices = max_verts; pscene->max_indices = max_indices; - pscene->submesh.indice_start = 0; - pscene->submesh.indice_count = 0; + memset( &pscene->submesh, 0, sizeof(mdl_submesh) ); v3_fill( pscene->bbx[0], 999999.9f ); v3_fill( pscene->bbx[1], -999999.9f ); @@ -158,29 +157,26 @@ VG_STATIC void scene_copy_slice( scene *pscene, mdl_submesh *sm ) __attribute__((warn_unused_result)) VG_STATIC scene *scene_fix( void *lin_alloc, scene *pscene ) { - u32 vertex_length = pscene->vertex_count * sizeof(mdl_vert), - index_length = pscene->indice_count * sizeof(u32), + return pscene; + u32 vertex_count = pscene->vertex_count, + indice_count = pscene->indice_count, + vertex_length = vertex_count * sizeof(mdl_vert), + index_length = indice_count * sizeof(u32), tot_size = sizeof(scene) + vertex_length + index_length; - scene *src_scene = pscene; - mdl_vert *src_verts = pscene->arrvertices; - u32 *src_indices = pscene->arrindices; + /* copy down index data */ + void *dst_indices = pscene->arrvertices + vertex_length; + memmove( dst_indices, pscene->arrindices, index_length ); - scene *dst_scene = vg_linear_resize( lin_alloc, pscene, tot_size ); - memcpy( dst_scene, src_scene, sizeof(scene) ); + /* realloc */ + pscene = vg_linear_resize( lin_alloc, pscene, tot_size ); - void *dst_verts = dst_scene+1, - *dst_indices = dst_verts + vertex_length; - - memcpy( dst_verts, src_verts, vertex_length ); - memcpy( dst_indices, src_indices, index_length ); - - dst_scene->arrvertices = dst_verts; - dst_scene->arrindices = dst_indices; - dst_scene->max_vertices = pscene->vertex_count; - dst_scene->max_indices = pscene->indice_count; + pscene->arrvertices = (mdl_vert *)(pscene+1); + pscene->arrindices = (u32 *)(pscene->arrvertices+vertex_count); + pscene->max_vertices = vertex_count; + pscene->max_indices = indice_count; - return dst_scene; + return pscene; } #if 0