Skip to content

Commit

Permalink
md3filter: Remove artificial export limits
Browse files Browse the repository at this point in the history
Ideally the file size should be calculated and allow up to 2GB which
is unlikely to be run into. (MD2 export doesn't enforce limits either
and has the exact same issue MD3 now has [invalid beyond 2GB].)
  • Loading branch information
zturtleman committed Sep 14, 2019
1 parent 6aad562 commit aa55fb2
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/libmm3d/md3filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1920,13 +1920,6 @@ Model::ModelErrorE Md3Filter::writeSectionFile( const char * filename, Md3Filter
}
}

if ( numFrames > MD3_MAX_FRAMES )
{
log_error( "Number of frames(%d) is larger than %d\n.\n", numFrames, MD3_MAX_FRAMES );
m_model->setFilterSpecificError( transll( QT_TRANSLATE_NOOP( "LowLevel", "Too many animation frames for MD3 export." ) ).c_str() );
return Model::ERROR_FILTER_SPECIFIC;
}

if ( animCount == 0 )
{
animCount = 1;
Expand Down Expand Up @@ -1954,10 +1947,6 @@ Model::ModelErrorE Md3Filter::writeSectionFile( const char * filename, Md3Filter
MeshList::iterator mlit;

int32_t numMeshes = 0;
size_t maxMeshTris = 0;
size_t maxMeshVerts = 0;

std::string groupName;

for ( mlit = meshes.begin(); mlit != meshes.end(); mlit++ )
{
Expand All @@ -1969,49 +1958,17 @@ Model::ModelErrorE Md3Filter::writeSectionFile( const char * filename, Md3Filter
if ( groupInSection( m_model->getGroupName( (*mlit).group ), section ) )
{
numMeshes++;
if ( (*mlit).faces.size() > maxMeshTris ) {
maxMeshTris = (*mlit).faces.size();
}
if ( (*mlit).vertices.size() > maxMeshVerts ) {
maxMeshVerts = (*mlit).vertices.size();
}
}
}
}

int32_t numSkins = 0;
if ( numTags > MD3_MAX_TAGS )
{
log_error( "Number of tags(%d) is larger than %d\n.\n", numTags, MD3_MAX_TAGS );
m_model->setFilterSpecificError( transll( QT_TRANSLATE_NOOP( "LowLevel", "Too many points for MD3 export." ) ).c_str() );
return Model::ERROR_FILTER_SPECIFIC;
}
if ( numMeshes > MD3_MAX_SURFACES )
{
log_error( "Number of groups(%d) is larger than %d\n.\n", numMeshes, MD3_MAX_SURFACES );
m_model->setFilterSpecificError( transll( QT_TRANSLATE_NOOP( "LowLevel", "Too many groups for MD3 export." ) ).c_str() );
return Model::ERROR_FILTER_SPECIFIC;
}
// numSkins is usually zero for MD3 header, there can be skins for each mesh though later
int32_t offsetFrames = HEADER_SIZE;
int32_t offsetTags = offsetFrames + numFrames * FRAME_SIZE;
int32_t offsetMeshes = offsetTags + numFrames * numTags * TAG_SIZE;
int32_t offsetEnd = offsetMeshes;

// MD3 limit tests
if ( maxMeshTris > MD3_MAX_TRIANGLES )
{
log_error( "Number of triangles(%d) is larger than %d\n.\n", maxMeshTris, MD3_MAX_TRIANGLES );
m_model->setFilterSpecificError( transll( QT_TRANSLATE_NOOP( "LowLevel", "Too many faces in a single group for MD3 export" ) ).c_str() );
return Model::ERROR_FILTER_SPECIFIC;
}
if ( maxMeshVerts > MD3_MAX_VERTS )
{
log_error( "Number of verticies(%d) is larger than %d\n.\n", maxMeshVerts, MD3_MAX_VERTS );
m_model->setFilterSpecificError( transll( QT_TRANSLATE_NOOP( "LowLevel", "Too many vertices in a single group for MD3 export" ) ).c_str() );
return Model::ERROR_FILTER_SPECIFIC;
}

// Open file for writing
Model::ModelErrorE err = Model::ERROR_NONE;
m_dst = openOutput( filename, err );
Expand Down

0 comments on commit aa55fb2

Please sign in to comment.