+VG_STATIC void world_add_blob( world_instance *world,
+ scene *pscene, ray_hit *hit )
+{
+ m4x3f transform;
+ v4f qsurface, qrandom;
+ v3f axis;
+
+ v3_cross( (v3f){0.0f,1.0f,0.0f}, hit->normal, axis );
+
+ float angle = v3_dot(hit->normal,(v3f){0.0f,1.0f,0.0f});
+ q_axis_angle( qsurface, axis, angle );
+ q_axis_angle( qrandom, (v3f){0.0f,1.0f,0.0f}, vg_randf()*VG_TAUf );
+ q_mul( qsurface, qrandom, qsurface );
+ q_m3x3( qsurface, transform );
+ v3_copy( hit->pos, transform[3] );
+
+ scene_vert verts[] =
+ {
+ { .co = { -1.00f, 0.0f, 0.0f } },
+ { .co = { 1.00f, 0.0f, 0.0f } },
+ { .co = { -1.00f, 1.2f, 0.0f } },
+ { .co = { 1.00f, 1.2f, 0.0f } },
+ { .co = { -0.25f, 2.0f, 0.0f } },
+ { .co = { 0.25f, 2.0f, 0.0f } }
+ };
+
+ const u32 indices[] = { 0,1,3, 0,3,2, 2,3,5, 2,5,4 };
+
+ if( pscene->vertex_count + vg_list_size(verts) > pscene->max_vertices )
+ vg_fatal_exit_loop( "Scene vertex buffer overflow" );
+
+ if( pscene->indice_count + vg_list_size(indices) > pscene->max_indices )
+ vg_fatal_exit_loop( "Scene index buffer overflow" );
+
+ scene_vert *dst_verts = &pscene->arrvertices[ pscene->vertex_count ];
+ u32 *dst_indices = &pscene->arrindices [ pscene->indice_count ];
+
+ scene_vert *ref = &world->scene_geo->arrvertices[ hit->tri[0] ];
+
+ for( u32 i=0; i<vg_list_size(verts); i++ )
+ {
+ scene_vert *pvert = &dst_verts[ i ],
+ *src = &verts[ i ];
+
+ m4x3_mulv( transform, src->co, pvert->co );
+ scene_vert_pack_norm( pvert, transform[1] );
+
+ v2_copy( ref->uv, pvert->uv );
+ }
+
+ for( u32 i=0; i<vg_list_size(indices); i++ )
+ dst_indices[i] = indices[i] + pscene->vertex_count;
+
+ pscene->vertex_count += vg_list_size(verts);
+ pscene->indice_count += vg_list_size(indices);
+}
+