Skip to content

Commit

Permalink
NifModel: new function to check for Starfield internal geometry format
Browse files Browse the repository at this point in the history
  • Loading branch information
fo76utils committed Oct 17, 2024
1 parent 8d61c83 commit e93cdb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/model/nifmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,30 @@ class spMeshFileImport
static bool processAllItems( NifModel * nif );
};

bool NifModel::checkInternalGeometry( const QModelIndex & blockIndex )
{
if ( !blockIndex.isValid() ) {
int n = getBlockCount();
for ( int i = 0; i < n; i++ ) {
QModelIndex b = getBlockIndex( i );
if ( isNiBlock( b, "BSGeometry" ) && !checkInternalGeometry( b ) )
return false;
}
return true;
}
if ( !isNiBlock( blockIndex, "BSGeometry" ) )
return true;
if ( get<quint32>( blockIndex, "Flags" ) & 0x0200 )
return true;
if ( QMessageBox::question( parentWindow, tr( "NifSkope warning" ),
tr( "This operation can only be performed on internal geometry. Convert meshes?" ) )
!= QMessageBox::Yes ) {
return false;
}
spMeshFileImport::processAllItems( this );
return bool( get<quint32>( blockIndex, "Flags" ) & 0x0200 );
}

bool NifModel::load( QIODevice & device, const char* fileName )
{
QSettings settings;
Expand Down
2 changes: 2 additions & 0 deletions src/model/nifmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class NifModel final : public BaseModel
// BaseModel

void clear() override final;
//! Check if a Starfield model uses internal geometry data, and optionally convert meshes. Returns true on success.
bool checkInternalGeometry( const QModelIndex & blockIndex );
bool load( QIODevice & device, const char* fileName = nullptr ) override final;
bool save( QIODevice & device ) const override final;

Expand Down

0 comments on commit e93cdb2

Please sign in to comment.