FBX C++ API Reference
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fbxprocessorshaderdependency.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_UTILS_PROCESSOR_SHADER_DEPENDENCY_H_
14 #define _FBXSDK_UTILS_PROCESSOR_SHADER_DEPENDENCY_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
21 
22 #include <fbxsdk/fbxsdk_nsbegin.h>
23 
28 {
30 
31 public:
32  FbxPropertyT<FbxString> RootProcessPath;
33 
35 
37 
38  void ClearProcessedFiles();
39 
43 protected:
44  virtual bool internal_ProcessObject(FbxObject* pObject);
46 
47 /*****************************************************************************************************************************
48 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
49 *****************************************************************************************************************************/
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 // Constructor / Destructor
52 protected:
53  virtual void ConstructProperties(bool pForceSet);
54  virtual void Destruct(bool pRecursive);
55 
56 public:
57 
58  class StringHash
59  {
60  public:
61  unsigned int operator()( const FbxString& pValue ) const
62  {
63  // from wikipedia.org
64  // Jenkins One-at-a-time hash
65 
66  size_t lLen = pValue.GetLen();
67  unsigned int lHashValue = 0;
68  const char* lData = pValue.Buffer();
69  for( size_t i = 0; i < lLen; ++i )
70  {
71  lHashValue += lData[i];
72  lHashValue += (lHashValue << 10);
73  lHashValue ^= (lHashValue >> 16);
74  }
75  lHashValue += (lHashValue << 3);
76  lHashValue ^= (lHashValue >> 11);
77  lHashValue += (lHashValue << 15);
78 
79  return lHashValue;
80  }
81  };
82 
83 protected:
84 
85  class FileDeleter
86  {
87  public:
88  FileDeleter( const char* pFileUrl ) : mFileUrl( pFileUrl) {};
89  ~FileDeleter()
90  {
91  if( !mFileUrl.IsEmpty() )
92  {
93  remove( mFileUrl );
94  }
95  };
96 
97  void Release() { mFileUrl = ""; }
98 
99  private: FbxString mFileUrl;
100  };
101 
102  // first == string as it appears in the file
103  // second == string URL
104  struct FilePathData
105  {
106  FbxString mOriginalStr;
107  FbxString mOriginalAbsUrl;
108 
109  FbxString mNewStr;
110  };
111 
112  typedef FbxDynamicArray< FilePathData > FilePathList;
113 
114  virtual bool GetIncludePaths( FbxString& pFile, FilePathList& pPaths, FbxXRefManager& pManager ) const;
115  virtual bool ReplaceUrls( const FbxString& pFileUrl, const FbxString& pNewFileUrl,
116  const FilePathList& pPaths ) const;
117 
118 private:
119  struct Dependency
120  {
121  FbxString mNewUrl;
122  FbxString mOriginalUrl;
123  };
124 
126 
127  DependMap mDependMap;
128 
129  FbxString mRootPath;
130 
131  FbxXRefManager mResolver;
132  int mSystemIndex;
133 
134  // magic number to limit the size of files we can parse =(
135  static const int sMaxFileSize;
136 
137  bool ParseDependencies( const FbxBindingTable& pTable );
138  bool AddDependency( FbxString& pFileUrl );
139  bool AddSystemPaths();
140 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
141 };
142 
143 #include <fbxsdk/fbxsdk_nsend.h>
144 
145 #endif /* _FBXSDK_UTILS_PROCESSOR_SHADER_DEPENDENCY_H_ */
#define FBXSDK_OBJECT_DECLARE(Class, Parent)
Macro used to declare a new class derived from FbxObject.
Definition: fbxobject.h:61
FBX SDK environment definition.
This object represents a standard hash map.
Definition: fbxhashmap.h:45
Utility class to manipulate strings.
Definition: fbxstring.h:66
FbxPropertyT< FbxString > AdditionalIncludePaths
The base class of most FBX objects.
Definition: fbxobject.h:157
This class manages external references to files.
Definition: fbxxref.h:30
Crawls CgFx and HLSL shader files, copies them, and all dependent shader files into the location spec...
char * Buffer()
Non-const buffer access.
The class and its derived classes(e.g.
Definition: fbxprocessor.h:27
Template class for dynamic array holding objects.
A binding table represents a collection of bindings from source types such as FbxObject, or FbxLayerElements to corresponding destinations, usually a third party shader parameters.
#define FBXSDK_DLL
Definition: fbxarch.h:173
virtual void Destruct(bool pRecursive)
Optional destructor override, automatically called by default destructor.
size_t GetLen() const
Get string length like "C" strlen().
virtual void ConstructProperties(bool pForceSet)
Optional property constructor override, automatically called by default constructor.