/* Transform and place vertices */
boxf bbxnew;
- box_copy( sm->bbx, bbxnew );
- m4x3_transform_aabb( transform, bbxnew );
+ box_init_inf( bbxnew );
+ m4x3_expand_aabb_aabb( transform, bbxnew, sm->bbx );
box_concat( ctx->bbx, bbxnew );
m3x3f normal_matrix;
v2_copy( src->uv, pvert->uv );
}
- for( u32 i=0; i<sm->indice_count; i++ )
- dst_indices[i] = src_indices[i] + ctx->vertex_count;
+ u32 real_indices = 0;
+ for( u32 i=0; i<sm->indice_count/3; i++ ){
+ u32 *src = &src_indices[i*3],
+ *dst = &dst_indices[real_indices];
+
+ v3f ab, ac, tn;
+ v3_sub( src_verts[src[2]].co, src_verts[src[0]].co, ab );
+ v3_sub( src_verts[src[1]].co, src_verts[src[0]].co, ac );
+ v3_cross( ac, ab, tn );
+
+#if 0
+ if( v3_length2( tn ) <= 0.00001f )
+ continue;
+#endif
+
+ dst[0] = src[0] + ctx->vertex_count;
+ dst[1] = src[1] + ctx->vertex_count;
+ dst[2] = src[2] + ctx->vertex_count;
+
+ real_indices += 3;
+ }
+
+ if( real_indices != sm->indice_count )
+ vg_warn( "Zero area triangles in model\n" );
ctx->vertex_count += sm->vertex_count;
- ctx->indice_count += sm->indice_count;
+ ctx->indice_count += real_indices;
}
/*