16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 22:59:19 +02:00

scale matchtolerance, add VNT2 chunk type

This commit is contained in:
milek7
2020-10-19 16:47:25 +02:00
parent 6a48293a40
commit 181249b1e7
3 changed files with 28 additions and 12 deletions

View File

@@ -183,14 +183,14 @@ void calculate_tangents(vertex_array &vertices, const index_array &indices, int
}
}
void calculate_indices( index_array &Indices, vertex_array &Vertices ) {
void calculate_indices( index_array &Indices, vertex_array &Vertices, float tolerancescale ) {
Indices.resize( Vertices.size() );
std::iota( std::begin( Indices ), std::end( Indices ), 0 );
// gather instances of used verices, replace the original vertex bank with it after you're done
vertex_array indexedvertices;
indexedvertices.reserve( std::max<size_t>( 100, Vertices.size() / 3 ) ); // optimistic guesstimate, but should reduce re-allocation somewhat
auto const matchtolerance { 1e-5f };
auto const matchtolerance { 1e-5f * tolerancescale };
for( auto idx = 0; idx < Indices.size(); ++idx ) {
if( Indices[ idx ] < idx ) {
// this index is pointing to a vertex out of linear order, i.e. it's an already processed duplicate we can skip