mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 18:23:15 +02:00
Added version tag to cache data
This commit is contained in:
parent
3a80de107d
commit
ab2fff46f1
@ -307,11 +307,8 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
|
|||||||
wxString bname = ep->GetCacheBaseName();
|
wxString bname = ep->GetCacheBaseName();
|
||||||
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
|
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
|
||||||
|
|
||||||
if( wxFileName::FileExists( cachename ) )
|
if( wxFileName::FileExists( cachename ) && loadCacheData( ep ) )
|
||||||
{
|
|
||||||
loadCacheData( ep );
|
|
||||||
return ep->sceneData;
|
return ep->sceneData;
|
||||||
}
|
|
||||||
|
|
||||||
ep->sceneData = m_Plugins->Load3DModel( aFileName );
|
ep->sceneData = m_Plugins->Load3DModel( aFileName );
|
||||||
|
|
||||||
@ -476,9 +473,6 @@ bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the file already exists on disk; just exit
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return S3D::WriteCache( fname, true, (SGNODE*)aCacheItem->sceneData );
|
return S3D::WriteCache( fname, true, (SGNODE*)aCacheItem->sceneData );
|
||||||
|
@ -574,6 +574,8 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
|
|||||||
istr.str( cfgLine.substr( 2 ) );
|
istr.str( cfgLine.substr( 2 ) );
|
||||||
istr >> vnum;
|
istr >> vnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
@ -32,6 +32,10 @@
|
|||||||
#include "3d_cache/sg/sg_shape.h"
|
#include "3d_cache/sg/sg_shape.h"
|
||||||
#include "3d_cache/sg/sg_helpers.h"
|
#include "3d_cache/sg/sg_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
|
// version format of the cache file
|
||||||
|
#define SG_VERSION_TAG "VERSION:1"
|
||||||
|
|
||||||
SCENEGRAPH::SCENEGRAPH( SGNODE* aParent ) : SGNODE( aParent )
|
SCENEGRAPH::SCENEGRAPH( SGNODE* aParent ) : SGNODE( aParent )
|
||||||
{
|
{
|
||||||
m_SGtype = S3D::SGTYPE_TRANSFORM;
|
m_SGtype = S3D::SGTYPE_TRANSFORM;
|
||||||
@ -366,6 +370,7 @@ bool SCENEGRAPH::WriteCache( std::ofstream& aFile, SGNODE* parentNode )
|
|||||||
// ensure unique node names
|
// ensure unique node names
|
||||||
ResetNodeIndex();
|
ResetNodeIndex();
|
||||||
ReNameNodes();
|
ReNameNodes();
|
||||||
|
aFile << "[" << SG_VERSION_TAG << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aFile.fail() )
|
if( aFile.fail() )
|
||||||
@ -462,6 +467,36 @@ bool SCENEGRAPH::ReadCache( std::ifstream& aFile, SGNODE* parentNode )
|
|||||||
|
|
||||||
if( NULL == parentNode )
|
if( NULL == parentNode )
|
||||||
{
|
{
|
||||||
|
// read the tag; if it's not the expected tag then we fail to read the cache file
|
||||||
|
do
|
||||||
|
{
|
||||||
|
char schar;
|
||||||
|
aFile.get( schar );
|
||||||
|
|
||||||
|
if( '[' != schar )
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
|
std::cerr << " * [INFO] corrupt data; missing left bracket at position ";
|
||||||
|
std::cerr << aFile.tellg() << "\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
aFile.get( schar );
|
||||||
|
|
||||||
|
while( ']' != schar && aFile.good() )
|
||||||
|
{
|
||||||
|
name.push_back( schar );
|
||||||
|
aFile.get( schar );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( name.compare( SG_VERSION_TAG ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} while( 0 );
|
||||||
|
|
||||||
// we need to read the tag and verify its type
|
// we need to read the tag and verify its type
|
||||||
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
|
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user