2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-06-09 05:48:49 +00:00
|
|
|
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2020-01-15 23:32:05 +00:00
|
|
|
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2015-12-11 06:37:42 +00:00
|
|
|
#define GLM_FORCE_RADIANS
|
|
|
|
|
2020-01-15 23:42:16 +00:00
|
|
|
#include <mutex>
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2016-03-20 00:45:55 +00:00
|
|
|
#include <wx/datetime.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <wx/dir.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <wx/filename.h>
|
2016-02-23 03:33:24 +00:00
|
|
|
#include <wx/log.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
2018-08-23 14:10:20 +00:00
|
|
|
#include <boost/version.hpp>
|
|
|
|
|
|
|
|
#if BOOST_VERSION >= 106800
|
|
|
|
#include <boost/uuid/detail/sha1.hpp>
|
|
|
|
#else
|
2016-01-14 02:49:40 +00:00
|
|
|
#include <boost/uuid/sha1.hpp>
|
2018-08-23 14:10:20 +00:00
|
|
|
#endif
|
2016-01-14 02:49:40 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
#include "3d_cache.h"
|
|
|
|
#include "3d_info.h"
|
|
|
|
#include "3d_plugin_manager.h"
|
2020-01-15 23:32:05 +00:00
|
|
|
#include "sg/scenegraph.h"
|
2015-12-09 07:30:48 +00:00
|
|
|
#include "plugins/3dapi/ifsg_api.h"
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-07-11 03:59:54 +00:00
|
|
|
#include <advanced_config.h>
|
2021-04-02 23:29:47 +00:00
|
|
|
#include <common.h> // For ExpandEnvVarSubstitutions
|
2020-01-15 23:32:05 +00:00
|
|
|
#include <filename_resolver.h>
|
2021-01-23 16:59:19 +00:00
|
|
|
#include <paths.h>
|
2020-01-15 23:32:05 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <project.h>
|
2020-08-09 10:41:45 +00:00
|
|
|
#include <settings/common_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-01-15 23:32:05 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-02-23 03:33:24 +00:00
|
|
|
#define MASK_3D_CACHE "3D_CACHE"
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-01-15 23:42:16 +00:00
|
|
|
static std::mutex mutex3D_cache;
|
|
|
|
static std::mutex mutex3D_cacheManager;
|
2016-04-11 03:03:39 +00:00
|
|
|
|
2018-08-23 14:10:20 +00:00
|
|
|
|
2020-04-16 16:11:21 +00:00
|
|
|
static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB ) noexcept
|
2016-03-20 00:45:55 +00:00
|
|
|
{
|
|
|
|
for( int i = 0; i < 20; ++i )
|
2020-12-16 18:19:28 +00:00
|
|
|
{
|
2016-03-20 00:45:55 +00:00
|
|
|
if( shaA[i] != shaB[i] )
|
|
|
|
return false;
|
2020-12-16 18:19:28 +00:00
|
|
|
}
|
2016-03-20 00:45:55 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-23 14:10:20 +00:00
|
|
|
|
2016-01-31 02:21:12 +00:00
|
|
|
static bool checkTag( const char* aTag, void* aPluginMgrPtr )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aTag || nullptr == aPluginMgrPtr )
|
2016-01-31 02:21:12 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
S3D_PLUGIN_MANAGER *pp = (S3D_PLUGIN_MANAGER*) aPluginMgrPtr;
|
|
|
|
|
|
|
|
return pp->CheckTag( aTag );
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2018-08-23 14:10:20 +00:00
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
static const wxString sha1ToWXString( const unsigned char* aSHA1Sum )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
unsigned char uc;
|
|
|
|
unsigned char tmp;
|
2016-01-14 02:49:40 +00:00
|
|
|
char sha1[41];
|
2015-12-08 07:31:57 +00:00
|
|
|
int j = 0;
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
for( int i = 0; i < 20; ++i )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-01-14 02:49:40 +00:00
|
|
|
uc = aSHA1Sum[i];
|
2015-12-08 07:31:57 +00:00
|
|
|
tmp = uc / 16;
|
|
|
|
|
|
|
|
if( tmp > 9 )
|
|
|
|
tmp += 87;
|
|
|
|
else
|
|
|
|
tmp += 48;
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
sha1[j++] = tmp;
|
2015-12-08 07:31:57 +00:00
|
|
|
tmp = uc % 16;
|
|
|
|
|
|
|
|
if( tmp > 9 )
|
|
|
|
tmp += 87;
|
|
|
|
else
|
|
|
|
tmp += 48;
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
sha1[j++] = tmp;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
sha1[j] = 0;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
return wxString::FromUTF8Unchecked( sha1 );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class S3D_CACHE_ENTRY
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
S3D_CACHE_ENTRY();
|
|
|
|
~S3D_CACHE_ENTRY();
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
void SetSHA1( const unsigned char* aSHA1Sum );
|
2020-04-05 19:51:48 +00:00
|
|
|
const wxString GetCacheBaseName();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-03-20 00:45:55 +00:00
|
|
|
wxDateTime modTime; // file modification time
|
2016-01-14 02:49:40 +00:00
|
|
|
unsigned char sha1sum[20];
|
2016-01-31 02:21:12 +00:00
|
|
|
std::string pluginInfo; // PluginName:Version string
|
|
|
|
SCENEGRAPH* sceneData;
|
|
|
|
S3DMODEL* renderData;
|
2020-12-16 18:19:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// prohibit assignment and default copy constructor
|
|
|
|
S3D_CACHE_ENTRY( const S3D_CACHE_ENTRY& source );
|
|
|
|
S3D_CACHE_ENTRY& operator=( const S3D_CACHE_ENTRY& source );
|
|
|
|
|
|
|
|
wxString m_CacheBaseName; // base name of cache file (a SHA1 digest)
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
S3D_CACHE_ENTRY::S3D_CACHE_ENTRY()
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
sceneData = nullptr;
|
|
|
|
renderData = nullptr;
|
2016-01-14 02:49:40 +00:00
|
|
|
memset( sha1sum, 0, 20 );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
S3D_CACHE_ENTRY::~S3D_CACHE_ENTRY()
|
|
|
|
{
|
2020-04-05 19:51:48 +00:00
|
|
|
delete sceneData;
|
2015-12-16 09:01:44 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr != renderData )
|
2015-12-16 09:01:44 +00:00
|
|
|
S3D::Destroy3DModel( &renderData );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aSHA1Sum )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] NULL passed for aSHA1Sum" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-02-23 03:33:24 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
memcpy( sha1sum, aSHA1Sum, 20 );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
const wxString S3D_CACHE_ENTRY::GetCacheBaseName()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
if( m_CacheBaseName.empty() )
|
2016-01-14 02:49:40 +00:00
|
|
|
m_CacheBaseName = sha1ToWXString( sha1sum );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
return m_CacheBaseName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
S3D_CACHE::S3D_CACHE()
|
|
|
|
{
|
2018-03-07 13:05:12 +00:00
|
|
|
m_FNResolver = new FILENAME_RESOLVER;
|
2020-04-05 19:51:48 +00:00
|
|
|
m_project = nullptr;
|
2015-12-08 07:31:57 +00:00
|
|
|
m_Plugins = new S3D_PLUGIN_MANAGER;
|
|
|
|
}
|
|
|
|
|
2018-08-23 14:10:20 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
S3D_CACHE::~S3D_CACHE()
|
|
|
|
{
|
|
|
|
FlushCache();
|
|
|
|
|
2020-08-09 10:41:45 +00:00
|
|
|
// We'll delete ".3dc" cache files older than this many days
|
2022-05-25 23:56:54 +00:00
|
|
|
int clearCacheInterval = 0;
|
|
|
|
|
|
|
|
if( Pgm().GetCommonSettings() )
|
2022-05-26 15:17:47 +00:00
|
|
|
clearCacheInterval = Pgm().GetCommonSettings()->m_System.clear_3d_cache_interval;
|
2020-08-09 10:41:45 +00:00
|
|
|
|
|
|
|
// An interval of zero means the user doesn't want to ever clear the cache
|
|
|
|
|
|
|
|
if( clearCacheInterval > 0 )
|
|
|
|
CleanCacheDir( clearCacheInterval );
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
delete m_FNResolver;
|
|
|
|
delete m_Plugins;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCachePtr )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2015-12-16 09:01:44 +00:00
|
|
|
if( aCachePtr )
|
2021-01-02 21:05:29 +00:00
|
|
|
*aCachePtr = nullptr;
|
2015-12-16 09:01:44 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile );
|
|
|
|
|
|
|
|
if( full3Dpath.empty() )
|
|
|
|
{
|
|
|
|
// the model cannot be found; we cannot proceed
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [3D model] could not find model '%s'\n" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, aModelFile );
|
2021-01-02 21:05:29 +00:00
|
|
|
return nullptr;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check cache if file is already loaded
|
2020-01-15 23:42:16 +00:00
|
|
|
std::lock_guard<std::mutex> lock( mutex3D_cache );
|
|
|
|
|
2018-03-07 13:05:12 +00:00
|
|
|
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi;
|
2015-12-08 07:31:57 +00:00
|
|
|
mi = m_CacheMap.find( full3Dpath );
|
|
|
|
|
|
|
|
if( mi != m_CacheMap.end() )
|
2015-12-16 09:01:44 +00:00
|
|
|
{
|
2016-03-20 20:21:54 +00:00
|
|
|
wxFileName fname( full3Dpath );
|
2016-03-20 00:45:55 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( fname.FileExists() ) // Only check if file exists. If not, it will
|
|
|
|
{ // use the same model in cache.
|
2021-07-11 04:35:38 +00:00
|
|
|
bool reload = ADVANCED_CFG::GetCfg().m_Skip3DModelMemoryCache;
|
2016-06-09 05:48:49 +00:00
|
|
|
wxDateTime fmdate = fname.GetModificationTime();
|
2016-03-20 00:45:55 +00:00
|
|
|
|
2016-06-09 05:48:49 +00:00
|
|
|
if( fmdate != mi->second->modTime )
|
2016-03-20 00:45:55 +00:00
|
|
|
{
|
2016-06-09 05:48:49 +00:00
|
|
|
unsigned char hashSum[20];
|
|
|
|
getSHA1( full3Dpath, hashSum );
|
|
|
|
mi->second->modTime = fmdate;
|
|
|
|
|
|
|
|
if( !isSHA1Same( hashSum, mi->second->sha1sum ) )
|
|
|
|
{
|
|
|
|
mi->second->SetSHA1( hashSum );
|
|
|
|
reload = true;
|
|
|
|
}
|
2016-03-20 00:45:55 +00:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( reload )
|
2016-03-20 00:45:55 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr != mi->second->sceneData )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
S3D::DestroyNode( mi->second->sceneData );
|
2021-01-02 21:05:29 +00:00
|
|
|
mi->second->sceneData = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2016-03-20 00:45:55 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr != mi->second->renderData )
|
2016-07-19 17:35:25 +00:00
|
|
|
S3D::Destroy3DModel( &mi->second->renderData );
|
2016-03-20 00:45:55 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
mi->second->sceneData = m_Plugins->Load3DModel( full3Dpath,
|
|
|
|
mi->second->pluginInfo );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2016-03-20 00:45:55 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr != aCachePtr )
|
2015-12-16 09:01:44 +00:00
|
|
|
*aCachePtr = mi->second;
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return mi->second->sceneData;
|
2015-12-16 09:01:44 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
// a cache item does not exist; search the Filename->Cachename map
|
2015-12-16 09:01:44 +00:00
|
|
|
return checkCache( full3Dpath, aCachePtr );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile )
|
|
|
|
{
|
|
|
|
return load( aModelFile );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2015-12-16 09:01:44 +00:00
|
|
|
if( aCachePtr )
|
2021-01-02 21:05:29 +00:00
|
|
|
*aCachePtr = nullptr;
|
2015-12-16 09:01:44 +00:00
|
|
|
|
2021-07-11 04:31:06 +00:00
|
|
|
unsigned char sha1sum[20];
|
|
|
|
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
|
|
|
|
m_CacheList.push_back( ep );
|
|
|
|
wxFileName fname( aFileName );
|
|
|
|
ep->modTime = fname.GetModificationTime();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
if( !getSHA1( aFileName, sha1sum ) || m_CacheDir.empty() )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-02-23 00:38:58 +00:00
|
|
|
// just in case we can't get a hash digest (for example, on access issues)
|
2015-12-08 07:31:57 +00:00
|
|
|
// or we do not have a configured cache file directory, we create an
|
|
|
|
// entry to prevent further attempts at loading the file
|
|
|
|
|
|
|
|
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
|
|
|
|
( aFileName, ep ) ).second == false )
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
|
|
|
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, aFileName );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
m_CacheList.pop_back();
|
|
|
|
delete ep;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-16 09:01:44 +00:00
|
|
|
if( aCachePtr )
|
|
|
|
*aCachePtr = ep;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
return nullptr;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
|
|
|
|
( aFileName, ep ) ).second == false )
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
|
|
|
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, aFileName );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
m_CacheList.pop_back();
|
|
|
|
delete ep;
|
2021-01-02 21:05:29 +00:00
|
|
|
return nullptr;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
if( aCachePtr )
|
|
|
|
*aCachePtr = ep;
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
ep->SetSHA1( sha1sum );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
wxString bname = ep->GetCacheBaseName();
|
|
|
|
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
|
|
|
|
|
2021-07-11 04:35:38 +00:00
|
|
|
if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && wxFileName::FileExists( cachename )
|
2021-07-11 03:59:54 +00:00
|
|
|
&& loadCacheData( ep ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
return ep->sceneData;
|
|
|
|
|
2016-01-31 02:21:12 +00:00
|
|
|
ep->sceneData = m_Plugins->Load3DModel( aFileName, ep->pluginInfo );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-07-11 04:35:38 +00:00
|
|
|
if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && nullptr != ep->sceneData )
|
2015-12-14 09:15:44 +00:00
|
|
|
saveCacheData( ep );
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return ep->sceneData;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
if( aFileName.empty() )
|
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] empty filename" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aSHA1Sum )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s\n * [BUG] NULL pointer passed for aMD5Sum" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
#ifdef _WIN32
|
2017-02-22 09:22:33 +00:00
|
|
|
FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
|
2020-12-16 18:19:28 +00:00
|
|
|
#else
|
2015-12-08 07:31:57 +00:00
|
|
|
FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
|
2020-12-16 18:19:28 +00:00
|
|
|
#endif
|
2016-02-23 00:38:58 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == fp )
|
2016-02-23 00:38:58 +00:00
|
|
|
return false;
|
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
boost::uuids::detail::sha1 dblock;
|
|
|
|
unsigned char block[4096];
|
|
|
|
size_t bsize = 0;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
while( ( bsize = fread( &block, 1, 4096, fp ) ) > 0 )
|
|
|
|
dblock.process_bytes( block, bsize );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
fclose( fp );
|
2016-01-14 02:49:40 +00:00
|
|
|
unsigned int digest[5];
|
|
|
|
dblock.get_digest( digest );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-01-14 02:49:40 +00:00
|
|
|
// ensure MSB order
|
|
|
|
for( int i = 0; i < 5; ++i )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-01-14 02:49:40 +00:00
|
|
|
int idx = i << 2;
|
|
|
|
unsigned int tmp = digest[i];
|
|
|
|
aSHA1Sum[idx+3] = tmp & 0xff;
|
|
|
|
tmp >>= 8;
|
|
|
|
aSHA1Sum[idx+2] = tmp & 0xff;
|
|
|
|
tmp >>= 8;
|
|
|
|
aSHA1Sum[idx+1] = tmp & 0xff;
|
|
|
|
tmp >>= 8;
|
|
|
|
aSHA1Sum[idx] = tmp & 0xff;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem )
|
|
|
|
{
|
|
|
|
wxString bname = aCacheItem->GetCacheBaseName();
|
|
|
|
|
|
|
|
if( bname.empty() )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( " * [3D model] cannot load cached model; no file hash available" ) );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CacheDir.empty() )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
|
|
|
|
|
2015-12-14 09:15:44 +00:00
|
|
|
if( !wxFileName::FileExists( fname ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( " * [3D model] cannot open file '%s'" ), fname.GetData() );
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr != aCacheItem->sceneData )
|
2015-12-14 09:15:44 +00:00
|
|
|
S3D::DestroyNode( (SGNODE*) aCacheItem->sceneData );
|
|
|
|
|
2016-01-31 02:21:12 +00:00
|
|
|
aCacheItem->sceneData = (SCENEGRAPH*)S3D::ReadCache( fname.ToUTF8(), m_Plugins, checkTag );
|
2015-12-14 09:15:44 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aCacheItem->sceneData )
|
2015-12-14 09:15:44 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aCacheItem )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * NULL passed for aCacheItem" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
if( nullptr == aCacheItem->sceneData )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * aCacheItem has no valid scene data" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString bname = aCacheItem->GetCacheBaseName();
|
|
|
|
|
|
|
|
if( bname.empty() )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( " * [3D model] cannot load cached model; no file hash available" ) );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CacheDir.empty() )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
|
|
|
|
|
|
|
|
if( wxFileName::Exists( fname ) )
|
|
|
|
{
|
2016-04-07 02:41:24 +00:00
|
|
|
if( !wxFileName::FileExists( fname ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
|
|
|
wxT( " * [3D model] path exists but is not a regular file '%s'" ), fname );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-31 02:21:12 +00:00
|
|
|
return S3D::WriteCache( fname.ToUTF8(), true, (SGNODE*)aCacheItem->sceneData,
|
2020-12-16 18:19:28 +00:00
|
|
|
aCacheItem->pluginInfo.c_str() );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
|
|
|
|
{
|
|
|
|
if( !m_ConfigDir.empty() )
|
|
|
|
return false;
|
|
|
|
|
2022-02-04 20:21:07 +00:00
|
|
|
wxFileName cfgdir( ExpandEnvVarSubstitutions( aConfigDir, m_project ), wxEmptyString );
|
2016-06-09 05:48:49 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
cfgdir.Normalize();
|
|
|
|
|
2015-12-14 07:41:15 +00:00
|
|
|
if( !cfgdir.DirExists() )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2015-12-14 07:41:15 +00:00
|
|
|
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2015-12-14 07:41:15 +00:00
|
|
|
if( !cfgdir.DirExists() )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( "%s:%s:%d\n * failed to create 3D configuration directory '%s'" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, cfgdir.GetPath() );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-14 07:41:15 +00:00
|
|
|
return false;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
2015-12-14 07:41:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_ConfigDir = cfgdir.GetPath();
|
|
|
|
|
|
|
|
// inform the file resolver of the config directory
|
|
|
|
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( "%s:%s:%d\n * could not set 3D Config Directory on filename resolver\n"
|
2022-02-04 22:44:59 +00:00
|
|
|
" * config directory: '%s'" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, m_ConfigDir );
|
2015-12-14 07:41:15 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-06-21 18:02:04 +00:00
|
|
|
// 3D cache data must go to a user's cache directory;
|
|
|
|
// unfortunately wxWidgets doesn't seem to provide
|
|
|
|
// functions to retrieve such a directory.
|
|
|
|
//
|
|
|
|
// 1. OSX: ~/Library/Caches/kicad/3d/
|
|
|
|
// 2. Linux: ${XDG_CACHE_HOME}/kicad/3d ~/.cache/kicad/3d/
|
|
|
|
// 3. MSWin: AppData\Local\kicad\3d
|
2021-01-23 16:59:19 +00:00
|
|
|
wxFileName cacheDir;
|
|
|
|
cacheDir.AssignDir( PATHS::GetUserCachePath() );
|
2022-02-04 20:21:07 +00:00
|
|
|
cacheDir.AppendDir( wxT( "3d" ) );
|
2016-06-21 18:02:04 +00:00
|
|
|
|
2021-01-23 16:59:19 +00:00
|
|
|
if( !cacheDir.DirExists() )
|
2015-12-14 07:41:15 +00:00
|
|
|
{
|
2021-01-23 16:59:19 +00:00
|
|
|
cacheDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-23 16:59:19 +00:00
|
|
|
if( !cacheDir.DirExists() )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2022-02-04 20:21:07 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
|
|
|
wxT( "%s:%s:%d\n * failed to create 3D cache directory '%s'" ),
|
2021-01-23 16:59:19 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, cacheDir.GetPath() );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2015-12-14 07:41:15 +00:00
|
|
|
return false;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:59:19 +00:00
|
|
|
m_CacheDir = cacheDir.GetPathWithSep();
|
2015-12-14 07:41:15 +00:00
|
|
|
return true;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
bool S3D_CACHE::SetProject( PROJECT* aProject )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-04-05 19:51:48 +00:00
|
|
|
m_project = aProject;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
bool hasChanged = false;
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
if( m_FNResolver->SetProject( aProject, &hasChanged ) && hasChanged )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
m_CacheMap.clear();
|
|
|
|
|
|
|
|
std::list< S3D_CACHE_ENTRY* >::iterator sL = m_CacheList.begin();
|
|
|
|
std::list< S3D_CACHE_ENTRY* >::iterator eL = m_CacheList.end();
|
|
|
|
|
|
|
|
while( sL != eL )
|
|
|
|
{
|
|
|
|
delete *sL;
|
|
|
|
++sL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CacheList.clear();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-17 22:35:32 +00:00
|
|
|
void S3D_CACHE::SetProgramBase( PGM_BASE* aBase )
|
|
|
|
{
|
|
|
|
m_FNResolver->SetProgramBase( aBase );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-16 16:11:21 +00:00
|
|
|
FILENAME_RESOLVER* S3D_CACHE::GetResolver() noexcept
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
return m_FNResolver;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
std::list< wxString > const* S3D_CACHE::GetFileFilters() const
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
return m_Plugins->GetFileFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-21 00:54:34 +00:00
|
|
|
void S3D_CACHE::FlushCache( bool closePlugins )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
std::list< S3D_CACHE_ENTRY* >::iterator sCL = m_CacheList.begin();
|
|
|
|
std::list< S3D_CACHE_ENTRY* >::iterator eCL = m_CacheList.end();
|
|
|
|
|
|
|
|
while( sCL != eCL )
|
|
|
|
{
|
|
|
|
delete *sCL;
|
|
|
|
++sCL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CacheList.clear();
|
2016-02-21 00:54:34 +00:00
|
|
|
m_CacheMap.clear();
|
|
|
|
|
|
|
|
if( closePlugins )
|
|
|
|
ClosePlugins();
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
void S3D_CACHE::ClosePlugins()
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-04-05 19:51:48 +00:00
|
|
|
if( m_Plugins )
|
2015-12-08 07:31:57 +00:00
|
|
|
m_Plugins->ClosePlugins();
|
|
|
|
}
|
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
|
2015-12-16 22:21:30 +00:00
|
|
|
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
S3D_CACHE_ENTRY* cp = nullptr;
|
2015-12-16 09:01:44 +00:00
|
|
|
SCENEGRAPH* sp = load( aModelFileName, &cp );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( !sp )
|
2021-01-02 21:05:29 +00:00
|
|
|
return nullptr;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
if( !cp )
|
|
|
|
{
|
2018-08-23 14:10:20 +00:00
|
|
|
wxLogTrace( MASK_3D_CACHE,
|
2022-02-04 20:21:07 +00:00
|
|
|
wxT( "%s:%s:%d\n * [BUG] model loaded with no associated S3D_CACHE_ENTRY" ),
|
2018-08-23 14:10:20 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__ );
|
2016-01-12 06:09:04 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
return nullptr;
|
2015-12-16 09:01:44 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
if( cp->renderData )
|
|
|
|
return cp->renderData;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2015-12-16 22:21:30 +00:00
|
|
|
S3DMODEL* mp = S3D::GetModel( sp );
|
2015-12-16 09:01:44 +00:00
|
|
|
cp->renderData = mp;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2015-12-16 09:01:44 +00:00
|
|
|
return mp;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
2016-01-15 00:28:28 +00:00
|
|
|
|
2020-08-09 10:41:45 +00:00
|
|
|
void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
|
|
|
|
{
|
|
|
|
wxDir dir;
|
|
|
|
wxString fileSpec = wxT( "*.3dc" );
|
|
|
|
wxArrayString fileList; // Holds list of ".3dc" files found in cache directory
|
|
|
|
size_t numFilesFound = 0;
|
|
|
|
|
|
|
|
wxFileName thisFile;
|
|
|
|
wxDateTime lastAccess, thresholdDate;
|
|
|
|
wxDateSpan durationInDays;
|
|
|
|
|
|
|
|
// Calc the threshold date above which we delete cache files
|
|
|
|
durationInDays.SetDays( aNumDaysOld );
|
|
|
|
thresholdDate = wxDateTime::Now() - durationInDays;
|
|
|
|
|
|
|
|
// If the cache directory can be found and opened, then we'll try and clean it up
|
|
|
|
if( dir.Open( m_CacheDir ) )
|
|
|
|
{
|
|
|
|
thisFile.SetPath( m_CacheDir ); // Set the base path to the cache folder
|
|
|
|
|
|
|
|
// Get a list of all the ".3dc" files in the cache directory
|
|
|
|
numFilesFound = dir.GetAllFiles( m_CacheDir, &fileList, fileSpec );
|
|
|
|
|
|
|
|
for( unsigned int i = 0; i < numFilesFound; i++ )
|
|
|
|
{
|
|
|
|
// Completes path to specific file so we can get its "last access" date
|
|
|
|
thisFile.SetFullName( fileList[i] );
|
|
|
|
|
|
|
|
// Only get "last access" time to compare against. Don't need the other 2 timestamps.
|
|
|
|
if( thisFile.GetTimes( &lastAccess, nullptr, nullptr ) )
|
|
|
|
{
|
|
|
|
if( lastAccess.IsEarlierThan( thresholdDate ) )
|
|
|
|
{
|
|
|
|
// This file is older than the threshold so delete it
|
|
|
|
wxRemoveFile( thisFile.GetFullPath() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-15 00:28:28 +00:00
|
|
|
|
2020-12-16 18:19:28 +00:00
|
|
|
|
2020-01-15 23:32:05 +00:00
|
|
|
S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
|
|
|
|
{
|
2020-01-15 23:42:16 +00:00
|
|
|
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
|
2020-01-15 23:32:05 +00:00
|
|
|
|
|
|
|
// Get the existing cache from the project
|
|
|
|
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );
|
|
|
|
|
|
|
|
if( !cache )
|
|
|
|
{
|
|
|
|
// Create a cache if there is not one already
|
|
|
|
cache = new S3D_CACHE();
|
|
|
|
|
|
|
|
wxFileName cfgpath;
|
2020-01-13 01:44:19 +00:00
|
|
|
cfgpath.AssignDir( SETTINGS_MANAGER::GetUserSettingsPath() );
|
2020-01-15 23:32:05 +00:00
|
|
|
cfgpath.AppendDir( wxT( "3d" ) );
|
|
|
|
|
|
|
|
cache->SetProgramBase( &Pgm() );
|
|
|
|
cache->Set3DConfigDir( cfgpath.GetFullPath() );
|
|
|
|
|
|
|
|
SetElem( ELEM_3DCACHE, cache );
|
|
|
|
aUpdateProjDir = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aUpdateProjDir )
|
2020-04-05 19:51:48 +00:00
|
|
|
cache->SetProject( this );
|
2020-01-15 23:32:05 +00:00
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FILENAME_RESOLVER* PROJECT::Get3DFilenameResolver()
|
|
|
|
{
|
|
|
|
return Get3DCacheManager()->GetResolver();
|
|
|
|
}
|