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 (C) 2018-2022 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, const EMBEDDED_FILES* aEmbeddedFiles )
215{
216 return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
217}
218
219
220SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr )
221{
222 if( aCachePtr )
223 *aCachePtr = nullptr;
224
225 HASH_128 hashSum;
227 m_CacheList.push_back( ep );
228 wxFileName fname( aFileName );
229 ep->modTime = fname.GetModificationTime();
230
231 if( !getHash( aFileName, hashSum ) || m_CacheDir.empty() )
232 {
233 // just in case we can't get a hash digest (for example, on access issues)
234 // or we do not have a configured cache file directory, we create an
235 // entry to prevent further attempts at loading the file
236
237 if( m_CacheMap.emplace( aFileName, ep ).second == false )
238 {
239 wxLogTrace( MASK_3D_CACHE,
240 wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
241 __FILE__, __FUNCTION__, __LINE__, aFileName );
242
243 m_CacheList.pop_back();
244 delete ep;
245 }
246 else
247 {
248 if( aCachePtr )
249 *aCachePtr = ep;
250 }
251
252 return nullptr;
253 }
254
255 if( m_CacheMap.emplace( aFileName, ep ).second == false )
256 {
257 wxLogTrace( MASK_3D_CACHE,
258 wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
259 __FILE__, __FUNCTION__, __LINE__, aFileName );
260
261 m_CacheList.pop_back();
262 delete ep;
263 return nullptr;
264 }
265
266 if( aCachePtr )
267 *aCachePtr = ep;
268
269 ep->SetHash( hashSum );
270
271 wxString bname = ep->GetCacheBaseName();
272 wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
273
274 if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && wxFileName::FileExists( cachename )
275 && loadCacheData( ep ) )
276 return ep->sceneData;
277
278 ep->sceneData = m_Plugins->Load3DModel( aFileName, ep->pluginInfo );
279
280 if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && nullptr != ep->sceneData )
281 saveCacheData( ep );
282
283 return ep->sceneData;
284}
285
286
287bool S3D_CACHE::getHash( const wxString& aFileName, HASH_128& aHash )
288{
289 if( aFileName.empty() )
290 {
291 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] empty filename" ),
292 __FILE__, __FUNCTION__, __LINE__ );
293
294 return false;
295 }
296
297#ifdef _WIN32
298 FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
299#else
300 FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
301#endif
302
303 if( nullptr == fp )
304 return false;
305
306 MMH3_HASH dblock( 0xA1B2C3D4 );
307 std::vector<char> block( 4096 );
308 size_t bsize = 0;
309
310 while( ( bsize = fread( block.data(), 1, 4096, fp ) ) > 0 )
311 dblock.add( block );
312
313 fclose( fp );
314 aHash = dblock.digest();
315 return true;
316}
317
318
320{
321 wxString bname = aCacheItem->GetCacheBaseName();
322
323 if( bname.empty() )
324 {
325 wxLogTrace( MASK_3D_CACHE,
326 wxT( " * [3D model] cannot load cached model; no file hash available" ) );
327
328 return false;
329 }
330
331 if( m_CacheDir.empty() )
332 {
333 wxLogTrace( MASK_3D_CACHE,
334 wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
335
336 return false;
337 }
338
339 wxString fname = m_CacheDir + bname + wxT( ".3dc" );
340
341 if( !wxFileName::FileExists( fname ) )
342 {
343 wxLogTrace( MASK_3D_CACHE, wxT( " * [3D model] cannot open file '%s'" ), fname.GetData() );
344 return false;
345 }
346
347 if( nullptr != aCacheItem->sceneData )
348 S3D::DestroyNode( (SGNODE*) aCacheItem->sceneData );
349
350 aCacheItem->sceneData = (SCENEGRAPH*)S3D::ReadCache( fname.ToUTF8(), m_Plugins, checkTag );
351
352 if( nullptr == aCacheItem->sceneData )
353 return false;
354
355 return true;
356}
357
358
360{
361 if( nullptr == aCacheItem )
362 {
363 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * NULL passed for aCacheItem" ),
364 __FILE__, __FUNCTION__, __LINE__ );
365
366 return false;
367 }
368
369 if( nullptr == aCacheItem->sceneData )
370 {
371 wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * aCacheItem has no valid scene data" ),
372 __FILE__, __FUNCTION__, __LINE__ );
373
374 return false;
375 }
376
377 wxString bname = aCacheItem->GetCacheBaseName();
378
379 if( bname.empty() )
380 {
381 wxLogTrace( MASK_3D_CACHE,
382 wxT( " * [3D model] cannot load cached model; no file hash available" ) );
383
384 return false;
385 }
386
387 if( m_CacheDir.empty() )
388 {
389 wxLogTrace( MASK_3D_CACHE,
390 wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
391
392 return false;
393 }
394
395 wxString fname = m_CacheDir + bname + wxT( ".3dc" );
396
397 if( wxFileName::Exists( fname ) )
398 {
399 if( !wxFileName::FileExists( fname ) )
400 {
401 wxLogTrace( MASK_3D_CACHE,
402 wxT( " * [3D model] path exists but is not a regular file '%s'" ), fname );
403
404 return false;
405 }
406 }
407
408 return S3D::WriteCache( fname.ToUTF8(), true, (SGNODE*)aCacheItem->sceneData,
409 aCacheItem->pluginInfo.c_str() );
410}
411
412
413bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
414{
415 if( !m_ConfigDir.empty() )
416 return false;
417
418 wxFileName cfgdir( ExpandEnvVarSubstitutions( aConfigDir, m_project ), wxEmptyString );
419
420 cfgdir.Normalize( FN_NORMALIZE_FLAGS );
421
422 if( !cfgdir.DirExists() )
423 {
424 cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
425
426 if( !cfgdir.DirExists() )
427 {
428 wxLogTrace( MASK_3D_CACHE,
429 wxT( "%s:%s:%d\n * failed to create 3D configuration directory '%s'" ),
430 __FILE__, __FUNCTION__, __LINE__, cfgdir.GetPath() );
431
432 return false;
433 }
434 }
435
436 m_ConfigDir = cfgdir.GetPath();
437
438 // inform the file resolver of the config directory
440 {
441 wxLogTrace( MASK_3D_CACHE,
442 wxT( "%s:%s:%d\n * could not set 3D Config Directory on filename resolver\n"
443 " * config directory: '%s'" ),
444 __FILE__, __FUNCTION__, __LINE__, m_ConfigDir );
445 }
446
447 // 3D cache data must go to a user's cache directory;
448 // unfortunately wxWidgets doesn't seem to provide
449 // functions to retrieve such a directory.
450 //
451 // 1. OSX: ~/Library/Caches/kicad/3d/
452 // 2. Linux: ${XDG_CACHE_HOME}/kicad/3d ~/.cache/kicad/3d/
453 // 3. MSWin: AppData\Local\kicad\3d
454 wxFileName cacheDir;
455 cacheDir.AssignDir( PATHS::GetUserCachePath() );
456 cacheDir.AppendDir( wxT( "3d" ) );
457
458 if( !cacheDir.DirExists() )
459 {
460 cacheDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
461
462 if( !cacheDir.DirExists() )
463 {
464 wxLogTrace( MASK_3D_CACHE,
465 wxT( "%s:%s:%d\n * failed to create 3D cache directory '%s'" ),
466 __FILE__, __FUNCTION__, __LINE__, cacheDir.GetPath() );
467
468 return false;
469 }
470 }
471
472 m_CacheDir = cacheDir.GetPathWithSep();
473 return true;
474}
475
476
478{
479 m_project = aProject;
480
481 bool hasChanged = false;
482
483 if( m_FNResolver->SetProject( aProject, &hasChanged ) && hasChanged )
484 {
485 m_CacheMap.clear();
486
487 std::list< S3D_CACHE_ENTRY* >::iterator sL = m_CacheList.begin();
488 std::list< S3D_CACHE_ENTRY* >::iterator eL = m_CacheList.end();
489
490 while( sL != eL )
491 {
492 delete *sL;
493 ++sL;
494 }
495
496 m_CacheList.clear();
497
498 return true;
499 }
500
501 return false;
502}
503
504
506{
508}
509
510
512{
513 return m_FNResolver;
514}
515
516
517std::list< wxString > const* S3D_CACHE::GetFileFilters() const
518{
519 return m_Plugins->GetFileFilters();
520}
521
522
523void S3D_CACHE::FlushCache( bool closePlugins )
524{
525 std::list< S3D_CACHE_ENTRY* >::iterator sCL = m_CacheList.begin();
526 std::list< S3D_CACHE_ENTRY* >::iterator eCL = m_CacheList.end();
527
528 while( sCL != eCL )
529 {
530 delete *sCL;
531 ++sCL;
532 }
533
534 m_CacheList.clear();
535 m_CacheMap.clear();
536
537 if( closePlugins )
538 ClosePlugins();
539}
540
541
543{
544 if( m_Plugins )
546}
547
548
549S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath,
550 const EMBEDDED_FILES* aEmbeddedFiles )
551{
552 S3D_CACHE_ENTRY* cp = nullptr;
553 SCENEGRAPH* sp = load( aModelFileName, aBasePath, &cp, aEmbeddedFiles );
554
555 if( !sp )
556 return nullptr;
557
558 if( !cp )
559 {
560 wxLogTrace( MASK_3D_CACHE,
561 wxT( "%s:%s:%d\n * [BUG] model loaded with no associated S3D_CACHE_ENTRY" ),
562 __FILE__, __FUNCTION__, __LINE__ );
563
564 return nullptr;
565 }
566
567 if( cp->renderData )
568 return cp->renderData;
569
570 S3DMODEL* mp = S3D::GetModel( sp );
571 cp->renderData = mp;
572
573 return mp;
574}
575
576void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
577{
578 wxDir dir;
579 wxString fileSpec = wxT( "*.3dc" );
580 wxArrayString fileList; // Holds list of ".3dc" files found in cache directory
581 size_t numFilesFound = 0;
582
583 wxFileName thisFile;
584 wxDateTime lastAccess, thresholdDate;
585 wxDateSpan durationInDays;
586
587 // Calc the threshold date above which we delete cache files
588 durationInDays.SetDays( aNumDaysOld );
589 thresholdDate = wxDateTime::Now() - durationInDays;
590
591 // If the cache directory can be found and opened, then we'll try and clean it up
592 if( dir.Open( m_CacheDir ) )
593 {
594 thisFile.SetPath( m_CacheDir ); // Set the base path to the cache folder
595
596 // Get a list of all the ".3dc" files in the cache directory
597 numFilesFound = dir.GetAllFiles( m_CacheDir, &fileList, fileSpec );
598
599 for( unsigned int i = 0; i < numFilesFound; i++ )
600 {
601 // Completes path to specific file so we can get its "last access" date
602 thisFile.SetFullName( fileList[i] );
603
604 // Only get "last access" time to compare against. Don't need the other 2 timestamps.
605 if( thisFile.GetTimes( &lastAccess, nullptr, nullptr ) )
606 {
607 if( lastAccess.IsEarlierThan( thresholdDate ) )
608 {
609 // This file is older than the threshold so delete it
610 wxRemoveFile( thisFile.GetFullPath() );
611 }
612 }
613 }
614 }
615}
#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)
Determines 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:365
Container for data for KiCad programs.
Definition: pgm_base.h:102
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:505
wxString m_CacheDir
Definition: 3d_cache.h:188
bool loadCacheData(S3D_CACHE_ENTRY *aCacheItem)
Definition: 3d_cache.cpp:319
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:523
bool Set3DConfigDir(const wxString &aConfigDir)
Sets the configuration directory to be used by the model manager for storing 3D model manager configu...
Definition: 3d_cache.cpp:413
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:549
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:220
PROJECT * m_project
Definition: 3d_cache.h:187
S3D_PLUGIN_MANAGER * m_Plugins
Definition: 3d_cache.h:185
bool saveCacheData(S3D_CACHE_ENTRY *aCacheItem)
Definition: 3d_cache.cpp:359
wxString m_ConfigDir
Definition: 3d_cache.h:189
std::list< wxString > const * GetFileFilters() const
Return the list of file filters retrieved from the plugins.
Definition: 3d_cache.cpp:517
FILENAME_RESOLVER * GetResolver() noexcept
Definition: 3d_cache.cpp:511
std::list< S3D_CACHE_ENTRY * > m_CacheList
cache entries
Definition: 3d_cache.h:178
bool SetProject(PROJECT *aProject)
Set the current project's working directory; this affects the model search path.
Definition: 3d_cache.cpp:477
void CleanCacheDir(int aNumDaysOld)
Delete up old cache files in cache directory.
Definition: 3d_cache.cpp:576
std::map< wxString, S3D_CACHE_ENTRY *, rsort_wxString > m_CacheMap
mapping of file names to cache names and data
Definition: 3d_cache.h:181
void ClosePlugins()
Unload plugins to free memory.
Definition: 3d_cache.cpp:542
bool getHash(const wxString &aFileName, HASH_128 &aHash)
Calculate the SHA1 hash of the given file.
Definition: 3d_cache.cpp:287
FILENAME_RESOLVER * m_FNResolver
Definition: 3d_cache.h:183
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:348
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 *))
Function ReadCache reads 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)
Function WriteCache writes the SGNODE tree to a binary cache file.
Definition: ifsg_api.cpp:157
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
Definition: ifsg_api.cpp:149
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
Definition: ifsg_api.cpp:338
SGLIB_API void Destroy3DModel(S3DMODEL **aModel)
Function Destroy3DModel frees memory used by an S3DMODEL structure and sets the pointer to the struct...
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:91
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39