X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=scene.h;h=340207582ba94cfe46d4dd017d178c3f89079e8f;hb=bdac014448b6ec968fe645f1581f321144f07dba;hp=b3d5062a86801deedf382a8c03906d6940e1c7fc;hpb=a64c18c5996fd5ac9601239f91b12275f04f9cd9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/scene.h b/scene.h index b3d5062..3402075 100644 --- a/scene.h +++ b/scene.h @@ -157,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