v3_copy( tn, ct->n );
if( v3_length2( ct->n ) <= 0.00001f ){
+#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING
vg_error( "Zero area triangle!\n" );
+#endif
return 0;
}
v3_sub( tri[1], tri[0], v0 );
v3_sub( tri[2], tri[0], v1 );
v3_cross( v0, v1, n );
+
+ if( v3_length2( n ) <= 0.00001f ){
+#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING
+ vg_error( "Zero area triangle!\n" );
+#endif
+ return 0;
+ }
+
v3_normalize( n );
/* find best feature */
v3_cross( v0, v1, n );
if( v3_length2( n ) <= 0.00001f ){
+#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING
vg_error( "Zero area triangle!\n" );
+#endif
return 0;
}
u32 real_indices = 0;
for( u32 i=0; i<sm->indice_count/3; i++ ){
- u32 *tri = &src_indices[i*3];
+ u32 *src = &src_indices[i*3],
+ *dst = &dst_indices[real_indices];
v3f ab, ac, tn;
- v3_sub( src_verts[tri[2]].co, src_verts[tri[0]].co, ab );
- v3_sub( src_verts[tri[1]].co, src_verts[tri[0]].co, ac );
+ 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
continue;
#endif
- dst_indices[real_indices+0] = tri[0] + ctx->vertex_count;
- dst_indices[real_indices+1] = tri[1] + ctx->vertex_count;
- dst_indices[real_indices+2] = tri[2] + ctx->vertex_count;
+ dst[0] = src[0] + ctx->vertex_count;
+ dst[1] = src[1] + ctx->vertex_count;
+ dst[2] = src[2] + ctx->vertex_count;
real_indices += 3;
}