KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_cache.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Cirilo Bernardo <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Copyright (C) 2022 CERN
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#define GLM_FORCE_RADIANS
27
28#include <mutex>
29#include <utility>
30
31#include <wx/datetime.h>
32#include <wx/dir.h>
33#include <wx/log.h>
34#include <wx/stdpaths.h>
35
36#include "3d_cache.h"
37#include "3d_info.h"
38#include "3d_plugin_manager.h"
39#include "sg/scenegraph.h"
41
42#include <advanced_config.h>
43#include <common.h> // For ExpandEnvVarSubstitutions
44#include <filename_resolver.h>
45#include <mmh3_hash.h>
46#include <paths.h>
47#include <pgm_base.h>
48#include <project.h>
51#include <wx_filename.h>
52
53
54#define MASK_3D_CACHE "3D_CACHE"
55
56static std::mutex mutex3D_cache;
57
58
59static bool checkTag( const char* aTag, void* aPluginMgrPtr )
60{
61 if( nullptr == aTag || nullptr == aPluginMgrPtr )
62 return false;
63
64 S3D_PLUGIN_MANAGER *pp = (S3D_PLUGIN_MANAGER*) aPluginMgrPtr;
65
66 return pp->CheckTag( aTag );
67}
68
69
71{
72public:
75
76 void SetHash( const HASH_128& aHash );
77 const wxString GetCacheBaseName();
78
79 wxDateTime modTime; // file modification time
81 std::string pluginInfo; // PluginName:Version string
84
85private:
86 // prohibit assignment and default copy constructor
89
90 wxString m_CacheBaseName; // base name of cache file
91};
92
93
95{
96 sceneData = nullptr;
97 renderData = nullptr;
98 m_hash.Clear();
99}
100
101
103{
104 delete sceneData;
105
106 if( nullptr != renderData )
108}
109
110
112{
113 m_hash = aHash;
114}
115
116
118{
119 if( m_CacheBaseName.empty() )
121
122 return m_CacheBaseName;
123}
124
125
127{
129 m_project = nullptr;
131}
132
133
135{
136 FlushCache();
137
138 delete m_FNResolver;
139 delete m_Plugins;
140}
141
142
143SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePath,
144 S3D_CACHE_ENTRY** aCachePtr, const EMBEDDED_FILES* aEmbeddedFiles )
145{
146 if( aCachePtr )
147 *aCachePtr = nullptr;
148
149 wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath, aEmbeddedFiles );
150
151 if( full3Dpath.empty() )
152 {
153 // the model cannot be found; we cannot proceed
154 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [3D model] could not find model '%s'\n" ),
155 __FILE__, __FUNCTION__, __LINE__, aModelFile );
156 return nullptr;
157 }
158
159 // check cache if file is already loaded
160 std::lock_guard<std::mutex> lock( mutex3D_cache );
161
162 std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi;
163 mi = m_CacheMap.find( full3Dpath );
164
165 if( mi != m_CacheMap.end() )
166 {
167 wxFileName fname( full3Dpath );
168
169 if( fname.FileExists() ) // Only check if file exists. If not, it will
170 { // use the same model in cache.
172 wxDateTime fmdate = fname.GetModificationTime();
173
174 if( fmdate != mi->second->modTime )
175 {
176 HASH_128 hashSum;
177 getHash( full3Dpath, hashSum );
178 mi->second->modTime = fmdate;
179
180 if( hashSum != mi->second->m_hash )
181 {
182 mi->second->SetHash( hashSum );
183 reload = true;
184 }
185 }
186
187 if( reload )
188 {
189 if( nullptr != mi->second->sceneData )
190 {
191 S3D::DestroyNode( mi->second->sceneData );
192 mi->second->sceneData = nullptr;
193 }
194
195 if( nullptr != mi->second->renderData )
196 S3D::Destroy3DModel( &mi->second->renderData );
197
198 mi->second->sceneData = m_Plugins->Load3DModel( full3Dpath,
199 mi->second->pluginInfo );
200 }
201 }
202
203 if( nullptr != aCachePtr )
204 *aCachePtr = mi->second;
205
206 return mi->second->sceneData;
207 }
208
209 // a cache item does not exist; search the Filename->Cachename map
210 return checkCache( full3Dpath, aCachePtr );
211}
212
213
214SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath,
215 const EMBEDDED_FILES* aEmbeddedFiles )
216{
217 return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
218}
219
220
221SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr )
222{
223 if( aCachePtr )
224 *aCachePtr = nullptr;
225
226 HASH_128 hashSum;
228 m_CacheList.push_back( ep );
229 wxFileName fname( aFileName );
230 ep->modTime = fname.GetModificationTime();
231
232 if( !getHash( aFileName, hashSum ) || m_CacheDir.empty() )
233 {
234 // just in case we can't get a hash digest (for example, on access issues)
235 // or we do not have a configured cache file directory, we create an
236 // entry to prevent further attempts at loading the file
237
238 if( m_CacheMap.emplace( aFileName, ep ).second == false )
239 {
240 wxLogTrace( MASK_3D_CACHE,
241 wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
242 __FILE__, __FUNCTION__, __LINE__, aFileName );
243
244 m_CacheList.pop_back();
245 delete ep;
246 }
247 else
248 {
249 if( aCachePtr )
250 *aCachePtr = ep;
251 }
252
253 return nullptr;
254 }
255
256 if( m_CacheMap.emplace( aFileName, ep ).second == false )
257 {
258 wxLogTrace( MASK_3D_CACHE,
259 wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
260 __FILE__, __FUNCTION__, __LINE__, aFileName );
261
262 m_CacheList.pop_back();
263 delete ep;
264 return nullptr;
265 }
266
267 if( aCachePtr )
268 *aCachePtr = ep;
269
270 ep->SetHash( hashSum );
271
272 wxString bname = ep->GetCacheBaseName();
273 wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
274
275 if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && wxFileName::FileExists( cachename )
276 && loadCacheData( ep ) )
277 return ep->sceneData;
278
279 ep->sceneData = m_Plugins->Load3DModel( aFileName, ep->pluginInfo );
280
281 if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && nullptr != ep->sceneData )
282 saveCacheData( ep );
283
284 return ep->sceneData;
285}
286
287
288bool S3D_CACHE::getHash( const wxString& aFileName, HASH_128& aHash )
289{
290 if( aFileName.empty() )
291 {
292 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] empty filename" ),
293 __FILE__, __FUNCTION__, __LINE__ );
294
295 return false;
296 }
297
298#ifdef _WIN32
299 FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
300#else
301 FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
302#endif
303
304 if( nullptr == fp )
305 return false;
306
307 MMH3_HASH dblock( 0xA1B2C3D4 );
308 std::vector<char> block( 4096 );
309 size_t bsize = 0;
310
311 while( ( bsize = fread( block.data(), 1, 4096, fp ) ) > 0 )
312 dblock.add( block );
313
314 fclose( fp );
315 aHash = dblock.digest();
316 return true;
317}
318
319
321{
322 wxString bname = aCacheItem->GetCacheBaseName();
323
324 if( bname.empty() )
325 {
326 wxLogTrace( MASK_3D_CACHE,
327 wxT( " * [3D model] cannot load cached model; no file hash available" ) );
328
329 return false;
330 }
331
332 if( m_CacheDir.empty() )
333 {
334 wxLogTrace( MASK_3D_CACHE,
335 wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
336
337 return false;
338 }
339
340 wxString fname = m_CacheDir + bname + wxT( ".3dc" );
341
342 if( !wxFileName::FileExists( fname ) )
343 {
344 wxLogTrace( MASK_3D_CACHE, wxT( " * [3D model] cannot open file '%s'" ), fname.GetData() );
345 return false;
346 }
347
348 if( nullptr != aCacheItem->sceneData )
349 S3D::DestroyNode( (SGNODE*) aCacheItem->sceneData );
350
351 aCacheItem->sceneData = (SCENEGRAPH*)S3D::ReadCache( fname.ToUTF8(), m_Plugins, checkTag );
352
353 if( nullptr == aCacheItem->sceneData )
354 return false;
355
356 return true;
357}
358
359
361{
362 if( nullptr == aCacheItem )
363 {
364 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * NULL passed for aCacheItem" ),
365 __FILE__, __FUNCTION__, __LINE__ );
366
367 return false;
368 }
369
370 if( nullptr == aCacheItem->sceneData )
371 {
372 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * aCacheItem has no valid scene data" ),
373 __FILE__, __FUNCTION__, __LINE__ );
374
375 return false;
376 }
377
378 wxString bname = aCacheItem->GetCacheBaseName();
379
380 if( bname.empty() )
381 {
382 wxLogTrace( MASK_3D_CACHE,
383 wxT( " * [3D model] cannot load cached model; no file hash available" ) );
384
385 return false;
386 }
387
388 if( m_CacheDir.empty() )
389 {
390 wxLogTrace( MASK_3D_CACHE,
391 wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
392
393 return false;
394 }
395
396 wxString fname = m_CacheDir + bname + wxT( ".3dc" );
397
398 if( wxFileName::Exists( fname ) )
399 {
400 if( !wxFileName::FileExists( fname ) )
401 {
402 wxLogTrace( MASK_3D_CACHE,
403 wxT( " * [3D model] path exists but is not a regular file '%s'" ), fname );
404
405 return false;
406 }
407 }
408
409 return S3D::WriteCache( fname.ToUTF8(), true, (SGNODE*)aCacheItem->sceneData,
410 aCacheItem->pluginInfo.c_str() );
411}
412
413
414bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
415{
416 if( !m_ConfigDir.empty() )
417 return false;
418
419 wxFileName cfgdir( ExpandEnvVarSubstitutions( aConfigDir, m_project ), wxEmptyString );
420
421 cfgdir.Normalize( FN_NORMALIZE_FLAGS );
422
423 if( !cfgdir.DirExists() )
424 {
425 cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
426
427 if( !cfgdir.DirExists() )
428 {
429 wxLogTrace( MASK_3D_CACHE,
430 wxT( "%s:%s:%d\n * failed to create 3D configuration directory '%s'" ),
431 __FILE__, __FUNCTION__, __LINE__, cfgdir.GetPath() );
432
433 return false;
434 }
435 }
436
437 m_ConfigDir = cfgdir.GetPath();
438
439 // inform the file resolver of the config directory
441 {
442 wxLogTrace( MASK_3D_CACHE,
443 wxT( "%s:%s:%d\n * could not set 3D Config Directory on filename resolver\n"
444 " * config directory: '%s'" ),
445 __FILE__, __FUNCTION__, __LINE__, m_ConfigDir );
446 }
447
448 // 3D cache data must go to a user's cache directory;
449 // unfortunately wxWidgets doesn't seem to provide
450 // functions to retrieve such a directory.
451 //
452 // 1. OSX: ~/Library/Caches/kicad/3d/
453 // 2. Linux: ${XDG_CACHE_HOME}/kicad/3d ~/.cache/kicad/3d/
454 // 3. MSWin: AppData\Local\kicad\3d
455 wxFileName cacheDir;
456 cacheDir.AssignDir( PATHS::GetUserCachePath() );
457 cacheDir.AppendDir( wxT( "3d" ) );
458
459 if( !cacheDir.DirExists() )
460 {
461 cacheDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
462
463 if( !cacheDir.DirExists() )
464 {
465 wxLogTrace( MASK_3D_CACHE,
466 wxT( "%s:%s:%d\n * failed to create 3D cache directory '%s'" ),
467 __FILE__, __FUNCTION__, __LINE__, cacheDir.GetPath() );
468
469 return false;
470 }
471 }
472
473 m_CacheDir = cacheDir.GetPathWithSep();
474 return true;
475}
476
477
479{
480 m_project = aProject;
481
482 bool hasChanged = false;
483
484 if( m_FNResolver->SetProject( aProject, &hasChanged ) && hasChanged )
485 {
486 m_CacheMap.clear();
487
488 std::list< S3D_CACHE_ENTRY* >::iterator sL = m_CacheList.begin();
489 std::list< S3D_CACHE_ENTRY* >::iterator eL = m_CacheList.end();
490
491 while( sL != eL )
492 {
493 delete *sL;
494 ++sL;
495 }
496
497 m_CacheList.clear();
498
499 return true;
500 }
501
502 return false;
503}
504
505
507{
509}
510
511
513{
514 return m_FNResolver;
515}
516
517
518std::list< wxString > const* S3D_CACHE::GetFileFilters() const
519{
520 return m_Plugins->GetFileFilters();
521}
522
523
524void S3D_CACHE::FlushCache( bool closePlugins )
525{
526 std::list< S3D_CACHE_ENTRY* >::iterator sCL = m_CacheList.begin();
527 std::list< S3D_CACHE_ENTRY* >::iterator eCL = m_CacheList.end();
528
529 while( sCL != eCL )
530 {
531 delete *sCL;
532 ++sCL;
533 }
534
535 m_CacheList.clear();
536 m_CacheMap.clear();
537
538 if( closePlugins )
539 ClosePlugins();
540}
541
542
544{
545 if( m_Plugins )
547}
548
549
550S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath,
551 const EMBEDDED_FILES* aEmbeddedFiles )
552{
553 S3D_CACHE_ENTRY* cp = nullptr;
554 SCENEGRAPH* sp = load( aModelFileName, aBasePath, &cp, aEmbeddedFiles );
555
556 if( !sp )
557 return nullptr;
558
559 if( !cp )
560 {
561 wxLogTrace( MASK_3D_CACHE,
562 wxT( "%s:%s:%d\n * [BUG] model loaded with no associated S3D_CACHE_ENTRY" ),
563 __FILE__, __FUNCTION__, __LINE__ );
564
565 return nullptr;
566 }
567
568 if( cp->renderData )
569 return cp->renderData;
570
571 S3DMODEL* mp = S3D::GetModel( sp );
572 cp->renderData = mp;
573
574 return mp;
575}
576
577void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
578{
579 wxDir dir;
580 wxString fileSpec = wxT( "*.3dc" );
581 wxArrayString fileList; // Holds list of ".3dc" files found in cache directory
582 size_t numFilesFound = 0;
583
584 wxFileName thisFile;
585 wxDateTime lastAccess, thresholdDate;
586 wxDateSpan durationInDays;
587
588 // Calc the threshold date above which we delete cache files
589 durationInDays.SetDays( aNumDaysOld );
590 thresholdDate = wxDateTime::Now() - durationInDays;
591
592 // If the cache directory can be found and opened, then we'll try and clean it up
593 if( dir.Open( m_CacheDir ) )
594 {
595 thisFile.SetPath( m_CacheDir ); // Set the base path to the cache folder
596
597 // Get a list of all the ".3dc" files in the cache directory
598 numFilesFound = dir.GetAllFiles( m_CacheDir, &fileList, fileSpec );
599
600 for( unsigned int i = 0; i < numFilesFound; i++ )
601 {
602 // Completes path to specific file so we can get its "last access" date
603 thisFile.SetFullName( fileList[i] );
604
605 // Only get "last access" time to compare against. Don't need the other 2 timestamps.
606 if( thisFile.GetTimes( &lastAccess, nullptr, nullptr ) )
607 {
608 if( lastAccess.IsEarlierThan( thresholdDate ) )
609 {
610 // This file is older than the threshold so delete it
611 wxRemoveFile( thisFile.GetFullPath() );
612 }
613 }
614 }
615 }
616}
#define MASK_3D_CACHE
Definition: 3d_cache.cpp:54
static std::mutex mutex3D_cache
Definition: 3d_cache.cpp:56
static bool checkTag(const char *aTag, void *aPluginMgrPtr)
Definition: 3d_cache.cpp:59
defines the basic data associated with a single 3D model.
manages 3D model plugins
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Provide an extensible class to resolve 3D model paths.
bool Set3DConfigDir(const wxString &aConfigDir)
Set the user's configuration directory for 3D models.
bool SetProject(PROJECT *aProject, bool *flgChanged=nullptr)
Set the current KiCad project directory as the first entry in the model path list.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, const EMBEDDED_FILES *aFiles)
Determine the full path of the given file name.
A streaming C++ equivalent for MurmurHash3_x64_128.
Definition: mmh3_hash.h:60
FORCE_INLINE void add(const std::string &input)
Definition: mmh3_hash.h:95
FORCE_INLINE HASH_128 digest()
Definition: mmh3_hash.h:114
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
Definition: paths.cpp:409
Container for data for KiCad programs.
Definition: pgm_base.h:103
Container for project specific data.
Definition: project.h:64
Definition: 3d_cache.cpp:71
S3D_CACHE_ENTRY & operator=(const S3D_CACHE_ENTRY &source)
HASH_128 m_hash
Definition: 3d_cache.cpp:80
S3DMODEL * renderData
Definition: 3d_cache.cpp:83
~S3D_CACHE_ENTRY()
Definition: 3d_cache.cpp:102
SCENEGRAPH * sceneData
Definition: 3d_cache.cpp:82
S3D_CACHE_ENTRY(const S3D_CACHE_ENTRY &source)
void SetHash(const HASH_128 &aHash)
Definition: 3d_cache.cpp:111
const wxString GetCacheBaseName()
Definition: 3d_cache.cpp:117
std::string pluginInfo
Definition: 3d_cache.cpp:81
wxString m_CacheBaseName
Definition: 3d_cache.cpp:90
wxDateTime modTime
Definition: 3d_cache.cpp:79
S3D_CACHE_ENTRY()
Definition: 3d_cache.cpp:94
SCENEGRAPH * Load(const wxString &aModelFile, const wxString &aBasePath, const EMBEDDED_FILES *aEmbeddedFiles)
Attempt to load the scene data for a model.
Definition: 3d_cache.cpp:214
void SetProgramBase(PGM_BASE *aBase)
Set the filename resolver's pointer to the application's PGM_BASE instance.
Definition: 3d_cache.cpp:506
wxString m_CacheDir
Definition: 3d_cache.h:190
bool loadCacheData(S3D_CACHE_ENTRY *aCacheItem)
Definition: 3d_cache.cpp:320
virtual ~S3D_CACHE()
Definition: 3d_cache.cpp:134
void FlushCache(bool closePlugins=true)
Free all data in the cache and by default closes all plugins.
Definition: 3d_cache.cpp:524
bool Set3DConfigDir(const wxString &aConfigDir)
Set the configuration directory to be used by the model manager for storing 3D model manager configur...
Definition: 3d_cache.cpp:414
S3DMODEL * GetModel(const wxString &aModelFileName, const wxString &aBasePath, const EMBEDDED_FILES *aEmbeddedFiles)
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for displa...
Definition: 3d_cache.cpp:550
SCENEGRAPH * load(const wxString &aModelFile, const wxString &aBasePath, S3D_CACHE_ENTRY **aCachePtr=nullptr, const EMBEDDED_FILES *aEmbeddedFiles=nullptr)
Definition: 3d_cache.cpp:143
SCENEGRAPH * checkCache(const wxString &aFileName, S3D_CACHE_ENTRY **aCachePtr=nullptr)
Find or create cache entry for file name.
Definition: 3d_cache.cpp:221
PROJECT * m_project
Definition: 3d_cache.h:189
S3D_PLUGIN_MANAGER * m_Plugins
Definition: 3d_cache.h:187
bool saveCacheData(S3D_CACHE_ENTRY *aCacheItem)
Definition: 3d_cache.cpp:360
wxString m_ConfigDir
base configuration path for 3D items.
Definition: 3d_cache.h:191
std::list< wxString > const * GetFileFilters() const
Return the list of file filters retrieved from the plugins.
Definition: 3d_cache.cpp:518
FILENAME_RESOLVER * GetResolver() noexcept
Definition: 3d_cache.cpp:512
std::list< S3D_CACHE_ENTRY * > m_CacheList
Cache entries.
Definition: 3d_cache.h:180
bool SetProject(PROJECT *aProject)
Set the current project's working directory; this affects the model search path.
Definition: 3d_cache.cpp:478
void CleanCacheDir(int aNumDaysOld)
Delete up old cache files in cache directory.
Definition: 3d_cache.cpp:577
std::map< wxString, S3D_CACHE_ENTRY *, rsort_wxString > m_CacheMap
Mapping of file names to cache names and data.
Definition: 3d_cache.h:183
void ClosePlugins()
Unload plugins to free memory.
Definition: 3d_cache.cpp:543
bool getHash(const wxString &aFileName, HASH_128 &aHash)
Calculate the SHA1 hash of the given file.
Definition: 3d_cache.cpp:288
FILENAME_RESOLVER * m_FNResolver
Definition: 3d_cache.h:185
void ClosePlugins(void)
Iterate through all discovered plugins and closes them to reclaim memory.
SCENEGRAPH * Load3DModel(const wxString &aFileName, std::string &aPluginInfo)
std::list< wxString > const * GetFileFilters(void) const noexcept
Return the list of file filters; this will contain at least the default "All Files (*....
bool CheckTag(const char *aTag)
Check the given tag and returns true if the plugin named in the tag is not loaded or the plugin is lo...
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:45
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:351
The common library.
bool m_Skip3DModelMemoryCache
Skip reading/writing 3D model memory caches.
defines the API calls for the manipulation of SG* classes
SGLIB_API SGNODE * ReadCache(const char *aFileName, void *aPluginMgr, bool(*aTagCheck)(const char *, void *))
Read a binary cache file and creates an SGNODE tree.
Definition: ifsg_api.cpp:221
SGLIB_API bool WriteCache(const char *aFileName, bool overwrite, SGNODE *aNode, const char *aPluginInfo)
Write the SGNODE tree to a binary cache file.
Definition: ifsg_api.cpp:157
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Delete the given SG* class node.
Definition: ifsg_api.cpp:149
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Create an S3DMODEL representation of aNode (raw data, no transforms).
Definition: ifsg_api.cpp:338
SGLIB_API void Destroy3DModel(S3DMODEL **aModel)
Free memory used by an S3DMODEL structure and sets the pointer to the structure to NULL.
Definition: ifsg_api.cpp:403
see class PGM_BASE
A storage class for 128-bit hash value.
Definition: hash_128.h:36
void Clear()
Definition: hash_128.h:37
std::string ToString() const
Definition: hash_128.h:47
Store the a model based on meshes and materials.
Definition: c3dmodel.h:95
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39