- pscene->verts = buffer_reserve( pscene->verts, pscene->vertex_count,
- &pscene->vertex_cap, sm->vertex_count, sizeof(mdl_vert) );
- pscene->indices = buffer_reserve( pscene->indices, pscene->indice_count,
- &pscene->indice_cap, sm->indice_count, sizeof(u32) );
+ if( ctx->vertex_count + sm->vertex_count > ctx->max_vertices ){
+ vg_fatal_error( "Scene vertex buffer overflow (%u exceeds %u)\n",
+ ctx->vertex_count + sm->vertex_count,
+ ctx->max_vertices );
+ }
+
+ if( ctx->indice_count + sm->indice_count > ctx->max_indices ){
+ vg_fatal_error( "Scene index buffer overflow (%u exceeds %u)\n",
+ ctx->indice_count + sm->indice_count,
+ ctx->max_indices );
+ }
+
+ mdl_vert *src_verts = mdl_arritm( &mdl->verts, sm->vertex_start );
+ scene_vert *dst_verts = &ctx->arrvertices[ ctx->vertex_count ];
+
+ u32 *src_indices = mdl_arritm( &mdl->indices, sm->indice_start ),
+ *dst_indices = &ctx->arrindices[ ctx->indice_count ];
+
+ /* Transform and place vertices */
+ boxf bbxnew;
+ box_init_inf( bbxnew );
+ m4x3_expand_aabb_aabb( transform, bbxnew, sm->bbx );
+ box_concat( ctx->bbx, bbxnew );