fbxprocessorxref.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /****************************************************************************************
  2. Copyright (C) 2015 Autodesk, Inc.
  3. All rights reserved.
  4. Use of this software is subject to the terms of the Autodesk license agreement
  5. provided at the time of installation or download, or which otherwise accompanies
  6. this software in either electronic or hard copy form.
  7. ****************************************************************************************/
  8. //! \file fbxprocessorxref.h
  9. #ifndef _FBXSDK_UTILS_PROCESSOR_XREF_H_
  10. #define _FBXSDK_UTILS_PROCESSOR_XREF_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/core/base/fbxmap.h>
  13. #include <fbxsdk/utils/fbxprocessor.h>
  14. #include <fbxsdk/fbxsdk_nsbegin.h>
  15. /** This class contains objects
  16. * This class also provides access to global settings and take information.
  17. */
  18. class FBXSDK_DLL FbxProcessorXRefCopy : public FbxProcessor
  19. {
  20. FBXSDK_OBJECT_DECLARE(FbxProcessorXRefCopy, FbxProcessor);
  21. public:
  22. class FBXSDK_DLL MissingUrlHandler
  23. {
  24. public:
  25. virtual ~MissingUrlHandler();
  26. virtual void MissingUrl(const FbxString& pUrl, const FbxProperty&) = 0;
  27. };
  28. /**
  29. * \name Properties
  30. */
  31. //@{
  32. FbxPropertyT<FbxString> OutputDirectory;
  33. /** As we resolve xref and copy assets, do we update properties to
  34. * now use this relative path? Defaults to TRUE.
  35. */
  36. FbxPropertyT<FbxBool> UpdateProperties;
  37. /** Default to FALSE -- when set, this informs the processor to track
  38. * every properties that were modified during the scene processing.
  39. */
  40. FbxPropertyT<FbxBool> TrackUpdatedProperties;
  41. /** Default to TRUE -- when not set, files are only copied if one of
  42. * the following conditions is met:
  43. *
  44. * 1) Target does not exist
  45. * 2) Target has a different time
  46. * 3) Target has a different size
  47. */
  48. FbxPropertyT<FbxBool> ForceCopy;
  49. /** Default to TRUE -- when copying a file, also copy its modification
  50. * time. A bit of a requirement if you're not going to use ForceCopy.
  51. */
  52. FbxPropertyT<FbxBool> CopyFileTimes;
  53. //@}
  54. /** Optional callback; when set, this will be called when an Url cannot be
  55. * be copied because the source is not found.
  56. * Memory is owned by the client code, and will not be freed by us.
  57. */
  58. MissingUrlHandler* MissingUrlHandler;
  59. /** Since FbxProperty is an opaque type, we can't do an efficient operator <
  60. * on it, and must keep the data on the object, which can be compared through
  61. * pointers, and then we can further compare against the property name.
  62. */
  63. struct PropertyUpdate
  64. {
  65. FbxProperty mProperty;
  66. FbxString mOriginalValue;
  67. inline PropertyUpdate() {}
  68. inline PropertyUpdate(const FbxProperty& pProp, const FbxString& pVal) :
  69. mProperty(pProp), mOriginalValue(pVal) {}
  70. inline bool operator <(const PropertyUpdate& pOther) const
  71. {
  72. return strcmp(mProperty.GetName(), pOther.mProperty.GetName()) < 0;
  73. }
  74. };
  75. typedef FbxSet<PropertyUpdate> UpdateSet;
  76. typedef FbxMap<FbxObject*, UpdateSet> PropertyUpdateMap;
  77. /** All properties that were updated, with their original value.
  78. * Will always be empty if TrackUpdatedProperties
  79. * was not set before calling ProcessCollection/ProcessObject.
  80. * NOT cleared before each processing run.
  81. */
  82. PropertyUpdateMap& GetUpdatedProperties();
  83. /** If property tracking was enabled, goes through and reverts all changes
  84. * to the properties. Does not un-copy the files, naturally.
  85. */
  86. void RevertPropertyChanges();
  87. /** This is just a safety net to make sure RevertPropertyChanges is called when
  88. * this goes out of scope.
  89. */
  90. struct FBXSDK_DLL AutoRevertPropertyChanges
  91. {
  92. AutoRevertPropertyChanges(FbxProcessorXRefCopy* pCopy) : mXRefCopy(pCopy) {}
  93. ~AutoRevertPropertyChanges()
  94. {
  95. if( mXRefCopy )
  96. mXRefCopy->RevertPropertyChanges();
  97. }
  98. FbxProcessorXRefCopy* mXRefCopy;
  99. };
  100. /*****************************************************************************************************************************
  101. ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
  102. *****************************************************************************************************************************/
  103. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  104. protected:
  105. virtual void Construct(const FbxObject* pFrom);
  106. virtual void ConstructProperties(bool pForceSet);
  107. PropertyUpdateMap mUpdatedProperties;
  108. // Implements the rules specified for the ForceCopy property.
  109. // Also checks the ForceCopy property.
  110. bool ShouldCopyFile(const FbxString& pTarget, const FbxString& pSource) const;
  111. virtual bool internal_ProcessCollectionBegin (FbxCollection* pObject);
  112. virtual bool internal_ProcessCollectionEnd (FbxCollection* pObject);
  113. virtual bool internal_ProcessObject (FbxObject* pObject);
  114. bool ProcessPathProperty(FbxProperty &pProperty);
  115. virtual bool ValidPropertyForXRefCopy(FbxObject* pObject, FbxProperty& lProperty) const;
  116. #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
  117. };
  118. #include <fbxsdk/fbxsdk_nsend.h>
  119. #endif /* _FBXSDK_UTILS_PROCESSOR_XREF_H_ */