|
@@ -67,33 +67,6 @@ class ShapeAsset : public AssetBase
|
|
|
typedef AssetBase Parent;
|
|
|
typedef AssetPtr<ShapeAsset> ConcreteAssetPtr;
|
|
|
|
|
|
-protected:
|
|
|
- StringTableEntry mFileName;
|
|
|
- StringTableEntry mConstructorFileName;
|
|
|
- StringTableEntry mFilePath;
|
|
|
- StringTableEntry mConstructorFilePath;
|
|
|
- Resource<TSShape> mShape;
|
|
|
-
|
|
|
- StringTableEntry mDiffuseImposterFileName;
|
|
|
- StringTableEntry mDiffuseImposterPath;
|
|
|
-
|
|
|
- StringTableEntry mNormalImposterFileName;
|
|
|
- StringTableEntry mNormalImposterPath;
|
|
|
-
|
|
|
- //Material assets we're dependent on and use
|
|
|
- Vector<StringTableEntry> mMaterialAssetIds;
|
|
|
- Vector<AssetPtr<MaterialAsset>> mMaterialAssets;
|
|
|
-
|
|
|
- //Animation assets we're dependent on and use
|
|
|
- Vector<StringTableEntry> mAnimationAssetIds;
|
|
|
- Vector<AssetPtr<ShapeAnimationAsset>> mAnimationAssets;
|
|
|
-
|
|
|
- typedef Signal<void()> ShapeAssetChanged;
|
|
|
- ShapeAssetChanged mChangeSignal;
|
|
|
-
|
|
|
- typedef Signal<void(S32 index)> ShapeAssetArrayChanged;
|
|
|
- ShapeAssetArrayChanged mChangeArraySignal;
|
|
|
-
|
|
|
public:
|
|
|
enum ShapeAssetErrCode
|
|
|
{
|
|
@@ -115,6 +88,23 @@ public:
|
|
|
return mErrCodeStrings[errCode - Parent::Extended];
|
|
|
};
|
|
|
|
|
|
+private:
|
|
|
+ StringTableEntry mShapeFile;
|
|
|
+ StringTableEntry mConstructorFileName;
|
|
|
+ StringTableEntry mDiffuseImposterFileName;
|
|
|
+ StringTableEntry mNormalImposterFileName;
|
|
|
+
|
|
|
+ //Material assets we're dependent on and use
|
|
|
+ Vector<StringTableEntry> mMaterialAssetIds;
|
|
|
+ Vector<AssetPtr<MaterialAsset>> mMaterialAssets;
|
|
|
+
|
|
|
+ //Animation assets we're dependent on and use
|
|
|
+ Vector<StringTableEntry> mAnimationAssetIds;
|
|
|
+ Vector<AssetPtr<ShapeAnimationAsset>> mAnimationAssets;
|
|
|
+
|
|
|
+ Resource<TSShape> mShape;
|
|
|
+public:
|
|
|
+
|
|
|
ShapeAsset();
|
|
|
virtual ~ShapeAsset();
|
|
|
|
|
@@ -127,8 +117,6 @@ public:
|
|
|
|
|
|
virtual void setDataField(StringTableEntry slotName, StringTableEntry array, StringTableEntry value);
|
|
|
|
|
|
- void initializeAsset() override;
|
|
|
-
|
|
|
/// Declare Console Object.
|
|
|
DECLARE_CONOBJECT(ShapeAsset);
|
|
|
|
|
@@ -139,10 +127,8 @@ public:
|
|
|
Resource<TSShape> getShapeResource() { load(); return mShape; }
|
|
|
|
|
|
void SplitSequencePathAndName(String& srcPath, String& srcName);
|
|
|
- StringTableEntry getShapeFileName() { return mFileName; }
|
|
|
- StringTableEntry getShapePath() { return mFilePath; }
|
|
|
|
|
|
- U32 getShapeFilenameHash() { return _StringTable::hashString(mFilePath); }
|
|
|
+ U32 getShapeFilenameHash() { return _StringTable::hashString(mShapeFile); }
|
|
|
|
|
|
Vector<AssetPtr<MaterialAsset>> getMaterialAssets() { return mMaterialAssets; }
|
|
|
|
|
@@ -164,26 +150,18 @@ public:
|
|
|
|
|
|
void _onResourceChanged(const Torque::Path& path);
|
|
|
|
|
|
- ShapeAssetChanged& getChangedSignal() { return mChangeSignal; }
|
|
|
- ShapeAssetArrayChanged& getChangedArraySignal() { return mChangeArraySignal; }
|
|
|
-
|
|
|
void setShapeFile(const char* pScriptFile);
|
|
|
- inline StringTableEntry getShapeFile(void) const { return mFileName; };
|
|
|
+ inline StringTableEntry getShapeFile(void) const { return mShapeFile; };
|
|
|
|
|
|
void setShapeConstructorFile(const char* pScriptFile);
|
|
|
inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; };
|
|
|
|
|
|
- inline StringTableEntry getShapeFilePath(void) const { return mFilePath; };
|
|
|
- inline StringTableEntry getShapeConstructorFilePath(void) const { return mConstructorFilePath; };
|
|
|
-
|
|
|
//Imposter images
|
|
|
void setDiffuseImposterFile(const char* pImageFile);
|
|
|
inline StringTableEntry getDiffuseImposterFile(void) const { return mDiffuseImposterFileName; };
|
|
|
- inline StringTableEntry getDiffuseImposterFilePath(void) const { return mDiffuseImposterPath; };
|
|
|
|
|
|
void setNormalImposterFile(const char* pImageFile);
|
|
|
inline StringTableEntry getNormalImposterFile(void) const { return mNormalImposterFileName; };
|
|
|
- inline StringTableEntry getNormalImposterFilePath(void) const { return mNormalImposterPath; };
|
|
|
|
|
|
static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
|
|
|
|
@@ -195,23 +173,34 @@ public:
|
|
|
#endif
|
|
|
|
|
|
protected:
|
|
|
- void onAssetRefresh(void) override;
|
|
|
+ // Asset Base callback
|
|
|
+ void initializeAsset(void) override;
|
|
|
+ void onAssetRefresh(void) override;
|
|
|
|
|
|
+ /// Taml callbacks.
|
|
|
+ void onTamlPreWrite(void) override;
|
|
|
+ void onTamlPostWrite(void) override;
|
|
|
+
|
|
|
+protected:
|
|
|
static bool setShapeFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setShapeFile(data); return false; }
|
|
|
static const char* getShapeFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeFile(); }
|
|
|
+ static bool writeShapeFile(void* obj, StringTableEntry pFieldName) { return static_cast<ShapeAsset*>(obj)->getShapeFile() != StringTable->EmptyString(); }
|
|
|
|
|
|
static bool setShapeConstructorFile(void* obj, const char* index, const char* data) { static_cast<ShapeAsset*>(obj)->setShapeConstructorFile(data); return false; }
|
|
|
static const char* getShapeConstructorFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeConstructorFile(); }
|
|
|
|
|
|
static bool setDiffuseImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setDiffuseImposterFile(data); return false; }
|
|
|
static const char* getDiffuseImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getDiffuseImposterFile(); }
|
|
|
+
|
|
|
static bool setNormalImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setNormalImposterFile(data); return false; }
|
|
|
static const char* getNormalImposterFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getNormalImposterFile(); }
|
|
|
};
|
|
|
|
|
|
-DefineConsoleType(TypeShapeAssetPtr, S32)
|
|
|
DefineConsoleType(TypeShapeAssetId, String)
|
|
|
|
|
|
+DECLARE_STRUCT(AssetPtr<ShapeAsset>)
|
|
|
+DefineConsoleType(TypeShapeAssetPtr, AssetPtr<ShapeAsset>)
|
|
|
+
|
|
|
#ifdef TORQUE_TOOLS
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// TypeAssetId GuiInspectorField Class
|
|
@@ -246,251 +235,256 @@ public:
|
|
|
DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetId);
|
|
|
static void consoleInit();
|
|
|
};
|
|
|
-#endif
|
|
|
|
|
|
-#pragma region Singular Asset Macros
|
|
|
-
|
|
|
-#define DECLARE_SHAPEASSET(className,name,changeFunc) public: \
|
|
|
- Resource<TSShape>m##name;\
|
|
|
- StringTableEntry m##name##Name; \
|
|
|
- StringTableEntry m##name##AssetId;\
|
|
|
- AssetPtr<ShapeAsset> m##name##Asset;\
|
|
|
-public: \
|
|
|
- const StringTableEntry get##name##File() const { return StringTable->insert(m##name##Name); }\
|
|
|
- void set##name##Name(const FileName &_in) { m##name##Name = _in;}\
|
|
|
- const AssetPtr<ShapeAsset> & get##name##Asset() const { return m##name##Asset; }\
|
|
|
- void set##name##Asset(const AssetPtr<ShapeAsset> &_in) { m##name##Asset = _in;}\
|
|
|
- \
|
|
|
- bool _set##name(StringTableEntry _in)\
|
|
|
- {\
|
|
|
- if(m##name##AssetId != _in || m##name##Name != _in)\
|
|
|
- {\
|
|
|
- if (m##name##Asset.notNull())\
|
|
|
- {\
|
|
|
- m##name##Asset->getChangedSignal().remove(this, &className::changeFunc);\
|
|
|
- }\
|
|
|
- if (_in == NULL || _in == StringTable->EmptyString())\
|
|
|
- {\
|
|
|
- m##name##Name = StringTable->EmptyString();\
|
|
|
- m##name##AssetId = StringTable->EmptyString();\
|
|
|
- m##name##Asset = NULL;\
|
|
|
- m##name = NULL;\
|
|
|
- return true;\
|
|
|
- }\
|
|
|
- \
|
|
|
- if (AssetDatabase.isDeclaredAsset(_in))\
|
|
|
- {\
|
|
|
- m##name##AssetId = _in;\
|
|
|
- \
|
|
|
- U32 assetState = ShapeAsset::getAssetById(m##name##AssetId, &m##name##Asset);\
|
|
|
- \
|
|
|
- if (ShapeAsset::Ok == assetState)\
|
|
|
- {\
|
|
|
- m##name##Name = StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- StringTableEntry assetId = ShapeAsset::getAssetIdByFilename(_in);\
|
|
|
- if (assetId != StringTable->EmptyString())\
|
|
|
- {\
|
|
|
- m##name##AssetId = assetId;\
|
|
|
- if (ShapeAsset::getAssetById(m##name##AssetId, &m##name##Asset) == ShapeAsset::Ok)\
|
|
|
- {\
|
|
|
- m##name##Name = StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- m##name##Name = _in;\
|
|
|
- m##name##AssetId = StringTable->EmptyString();\
|
|
|
- m##name##Asset = NULL;\
|
|
|
- }\
|
|
|
- }\
|
|
|
- }\
|
|
|
- if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\
|
|
|
- {\
|
|
|
- m##name = m##name##Asset->getShapeResource();\
|
|
|
- \
|
|
|
- m##name##Asset->getChangedSignal().notify(this, &className::changeFunc);\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- m##name = NULL;\
|
|
|
- }\
|
|
|
- \
|
|
|
- if(get##name() == StringTable->EmptyString())\
|
|
|
- return true;\
|
|
|
- \
|
|
|
- if (m##name##Asset.notNull() && m##name##Asset->getStatus() != ShapeAsset::Ok)\
|
|
|
- {\
|
|
|
- Con::errorf("%s(%s)::_set%s() - shape asset failure \"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, ShapeAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\
|
|
|
- return false; \
|
|
|
- }\
|
|
|
- else if (!m##name)\
|
|
|
- {\
|
|
|
- Con::errorf("%s(%s)::_set%s() - Couldn't load shape \"%s\"", macroText(className), getName(), macroText(name), _in);\
|
|
|
- return false;\
|
|
|
- }\
|
|
|
- return true;\
|
|
|
- }\
|
|
|
- \
|
|
|
- const StringTableEntry get##name() const\
|
|
|
- {\
|
|
|
- if (m##name##Asset && (m##name##Asset->getShapePath() != StringTable->EmptyString()))\
|
|
|
- return m##name##Asset->getShapePath();\
|
|
|
- else if (m##name##AssetId != StringTable->EmptyString())\
|
|
|
- return m##name##AssetId;\
|
|
|
- else if (m##name##Name != StringTable->EmptyString())\
|
|
|
- return m##name##Name;\
|
|
|
- else\
|
|
|
- return StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- Resource<TSShape> get##name##Resource() \
|
|
|
- {\
|
|
|
- return m##name;\
|
|
|
- }\
|
|
|
- bool is##name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); }
|
|
|
-
|
|
|
-#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
|
|
-
|
|
|
-#define INITPERSISTFIELD_SHAPEASSET(name, consoleClass, docs) \
|
|
|
- addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs)); \
|
|
|
- addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));
|
|
|
-
|
|
|
-#else
|
|
|
-
|
|
|
-#define INITPERSISTFIELD_SHAPEASSET(name, consoleClass, docs) \
|
|
|
- addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
|
|
|
- addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, assetText(name, asset reference.));
|
|
|
-
|
|
|
-#endif // SHOW_LEGACY_FILE_FIELDS
|
|
|
+#endif
|
|
|
|
|
|
-#pragma endregion
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// REFACTOR
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
|
|
|
-#pragma region Arrayed Asset Macros
|
|
|
-
|
|
|
-#define DECLARE_SHAPEASSET_ARRAY(className,name,max,changeFunc) public: \
|
|
|
- static const U32 sm##name##Count = max;\
|
|
|
- Resource<TSShape>m##name[max];\
|
|
|
- StringTableEntry m##name##Name[max]; \
|
|
|
- StringTableEntry m##name##AssetId[max];\
|
|
|
- AssetPtr<ShapeAsset> m##name##Asset[max];\
|
|
|
-public: \
|
|
|
- const StringTableEntry get##name##File(const U32& index) const { return m##name##Name[index]; }\
|
|
|
- void set##name##Name(const FileName &_in, const U32& index) { m##name##Name[index] = _in;}\
|
|
|
- const AssetPtr<ShapeAsset> & get##name##Asset(const U32& index) const { return m##name##Asset[index]; }\
|
|
|
- void set##name##Asset(const AssetPtr<ShapeAsset> &_in, const U32& index) { m##name##Asset[index] = _in;}\
|
|
|
- \
|
|
|
- bool _set##name(StringTableEntry _in, const U32& index)\
|
|
|
- {\
|
|
|
- if (m##name##Asset[index].notNull())\
|
|
|
- {\
|
|
|
- m##name##Asset[index]->getChangedSignal().remove(this, &className::changeFunc);\
|
|
|
- }\
|
|
|
- if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\
|
|
|
- {\
|
|
|
- if(index >= sm##name##Count || index < 0)\
|
|
|
- return false;\
|
|
|
- if (_in == NULL || _in == StringTable->EmptyString())\
|
|
|
- {\
|
|
|
- m##name##Name[index] = StringTable->EmptyString();\
|
|
|
- m##name##AssetId[index] = StringTable->EmptyString();\
|
|
|
- m##name##Asset[index] = NULL;\
|
|
|
- m##name[index] = NULL;\
|
|
|
- return true;\
|
|
|
- }\
|
|
|
- \
|
|
|
- if (AssetDatabase.isDeclaredAsset(_in))\
|
|
|
- {\
|
|
|
- m##name##AssetId[index] = _in;\
|
|
|
- \
|
|
|
- U32 assetState = ShapeAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]);\
|
|
|
- \
|
|
|
- if (ShapeAsset::Ok == assetState)\
|
|
|
- {\
|
|
|
- m##name##Name[index] = StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- StringTableEntry assetId = ShapeAsset::getAssetIdByFilename(_in);\
|
|
|
- if (assetId != StringTable->EmptyString())\
|
|
|
- {\
|
|
|
- m##name##AssetId[index] = assetId;\
|
|
|
- if (ShapeAsset::getAssetById(m##name##AssetId[index], &m##name##Asset[index]) == ShapeAsset::Ok)\
|
|
|
- {\
|
|
|
- m##name##Name[index] = StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- m##name##Name[index] = _in;\
|
|
|
- m##name##AssetId[index] = StringTable->EmptyString();\
|
|
|
- m##name##Asset[index] = NULL;\
|
|
|
- }\
|
|
|
- }\
|
|
|
- }\
|
|
|
- if (get##name(index) != StringTable->EmptyString() && m##name##Asset[index].notNull())\
|
|
|
- {\
|
|
|
- m##name[index] = m##name##Asset[index]->getShapeResource();\
|
|
|
- \
|
|
|
- m##name##Asset[index]->getChangedSignal().notify(this, &className::changeFunc);\
|
|
|
- }\
|
|
|
- else\
|
|
|
- {\
|
|
|
- m##name[index] = NULL;\
|
|
|
- }\
|
|
|
- \
|
|
|
- if(get##name(index) == StringTable->EmptyString())\
|
|
|
- return true;\
|
|
|
- \
|
|
|
- if (m##name##Asset[index].notNull() && m##name##Asset[index]->getStatus() != ShapeAsset::Ok)\
|
|
|
- {\
|
|
|
- Con::errorf("%s(%s)::_set%s(%i) - shape asset failure \"%s\" due to [%s]", macroText(className), getName(), macroText(name), index, _in, ShapeAsset::getAssetErrstrn(m##name##Asset[index]->getStatus()).c_str());\
|
|
|
- return false; \
|
|
|
- }\
|
|
|
- else if (!m##name[index])\
|
|
|
- {\
|
|
|
- Con::errorf("%s(%s)::_set%s(%i) - Couldn't load shape \"%s\"", macroText(className), getName(), macroText(name), index, _in);\
|
|
|
- return false; \
|
|
|
- }\
|
|
|
- return true;\
|
|
|
- }\
|
|
|
- \
|
|
|
- const StringTableEntry get##name(const U32& index) const\
|
|
|
- {\
|
|
|
- if (m##name##Asset[index] && (m##name##Asset[index]->getShapePath() != StringTable->EmptyString()))\
|
|
|
- return m##name##Asset[index]->getShapePath();\
|
|
|
- else if (m##name##AssetId[index] != StringTable->EmptyString())\
|
|
|
- return m##name##AssetId[index];\
|
|
|
- else if (m##name##Name[index] != StringTable->EmptyString())\
|
|
|
- return StringTable->insert(m##name##Name[index]);\
|
|
|
- else\
|
|
|
- return StringTable->EmptyString();\
|
|
|
- }\
|
|
|
- Resource<TSShape> get##name##Resource(const U32& index) \
|
|
|
- {\
|
|
|
- if(index >= sm##name##Count || index < 0)\
|
|
|
- return ResourceManager::get().load( "" );\
|
|
|
- return m##name[index];\
|
|
|
- }\
|
|
|
- bool is##name##Valid(const U32& id) {return (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok); }
|
|
|
-
|
|
|
-#ifdef TORQUE_SHOW_LEGACY_FILE_FIELDS
|
|
|
-
|
|
|
-#define INITPERSISTFIELD_SHAPEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
|
|
- addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, arraySize, assetText(name, docs)); \
|
|
|
- addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, arraySize, assetText(name, asset reference.));
|
|
|
-
|
|
|
-#else
|
|
|
-
|
|
|
-#define INITPERSISTFIELD_SHAPEASSET_ARRAY(name, arraySize, consoleClass, docs) \
|
|
|
- addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Name, consoleClass), _set##name##Data, & defaultProtectedGetFn, arraySize, assetText(name, docs), AbstractClassRep::FIELD_HideInInspectors); \
|
|
|
- addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, & defaultProtectedGetFn, arraySize,assetText(name, asset reference.));
|
|
|
-
|
|
|
-#endif // SHOW_LEGACY_FILE_FIELDS
|
|
|
+#pragma region Refactor Asset Macros
|
|
|
+
|
|
|
+#define DECLARE_SHAPEASSET_REFACTOR(className, name) \
|
|
|
+private: \
|
|
|
+ AssetPtr<ShapeAsset> m##name##Asset; \
|
|
|
+ StringTableEntry m##name##File = StringTable->EmptyString(); \
|
|
|
+public: \
|
|
|
+ void _set##name(StringTableEntry _in) { \
|
|
|
+ if (m##name##Asset.getAssetId() == _in) \
|
|
|
+ return; \
|
|
|
+ if(get##name##File() == _in) \
|
|
|
+ return; \
|
|
|
+ if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
|
|
+ { \
|
|
|
+ m##name##Asset = NULL; \
|
|
|
+ m##name##File = ""; \
|
|
|
+ return; \
|
|
|
+ } \
|
|
|
+ if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
+ { \
|
|
|
+ StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
+ AssetQuery query; \
|
|
|
+ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
+ if (foundAssetcount != 0) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = query.mAssetList[0]; \
|
|
|
+ } \
|
|
|
+ else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
+ if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
+ { \
|
|
|
+ ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
+ privateShape->setShapeFile(_in); \
|
|
|
+ shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
+ shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
+ } \
|
|
|
+ m##name##Asset = shapeAssetId; \
|
|
|
+ m##name##File = _in; \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ m##name##Asset = _in; \
|
|
|
+ m##name##File = get##name##File(); \
|
|
|
+ } \
|
|
|
+ }; \
|
|
|
+ \
|
|
|
+ inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \
|
|
|
+ Resource<TSShape> get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \
|
|
|
+ AssetPtr<ShapeAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
|
+ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false; } \
|
|
|
+ StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; }
|
|
|
+
|
|
|
+#define DECLARE_SHAPEASSET_NET_REFACTOR(className, name, mask) \
|
|
|
+private: \
|
|
|
+ AssetPtr<ShapeAsset> m##name##Asset; \
|
|
|
+ StringTableEntry m##name##File = StringTable->EmptyString(); \
|
|
|
+public: \
|
|
|
+ void _set##name(StringTableEntry _in) { \
|
|
|
+ if (m##name##Asset.getAssetId() == _in) \
|
|
|
+ return; \
|
|
|
+ if(get##name##File() == _in) \
|
|
|
+ return; \
|
|
|
+ if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
|
|
+ { \
|
|
|
+ m##name##Asset = NULL; \
|
|
|
+ m##name##File = ""; \
|
|
|
+ setMaskBits(mask); \
|
|
|
+ return; \
|
|
|
+ } \
|
|
|
+ if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
+ { \
|
|
|
+ StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
+ AssetQuery query; \
|
|
|
+ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
+ if (foundAssetcount != 0) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = query.mAssetList[0]; \
|
|
|
+ } \
|
|
|
+ else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
+ if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
+ { \
|
|
|
+ ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
+ privateShape->setShapeFile(_in); \
|
|
|
+ shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
+ shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
+ } \
|
|
|
+ m##name##Asset = shapeAssetId; \
|
|
|
+ m##name##File = _in; \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ m##name##Asset = _in; \
|
|
|
+ m##name##File = get##name##File(); \
|
|
|
+ } \
|
|
|
+ setMaskBits(mask); \
|
|
|
+ }; \
|
|
|
+ \
|
|
|
+ inline StringTableEntry _get##name##AssetId(void) const { return m##name##Asset.getAssetId(); } \
|
|
|
+ Resource<TSShape> get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \
|
|
|
+ AssetPtr<ShapeAsset> get##name##Asset(void) { return m##name##Asset; } \
|
|
|
+ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data)); return false; } \
|
|
|
+ StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; }
|
|
|
+
|
|
|
+#define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \
|
|
|
+ addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \
|
|
|
+ addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.));
|
|
|
+
|
|
|
+
|
|
|
+#define DECLARE_SHAPEASSET_ARRAY_REFACTOR(className, name, max) \
|
|
|
+private: \
|
|
|
+ AssetPtr<ShapeAsset> m##name##Asset[max]; \
|
|
|
+ StringTableEntry m##name##File[max] = {StringTable->EmptyString() }; \
|
|
|
+public: \
|
|
|
+ void _set##name(StringTableEntry _in, const U32& index){ \
|
|
|
+ if (m##name##Asset[index].getAssetId() == _in) \
|
|
|
+ return; \
|
|
|
+ if(get##name##File(index) == _in) \
|
|
|
+ return; \
|
|
|
+ if(_in == NULL || _in == StringTable->EmptyString() || _in == "") \
|
|
|
+ { \
|
|
|
+ m##name##Asset[index] = NULL; \
|
|
|
+ m##name##File[index] = ""; \
|
|
|
+ return; \
|
|
|
+ } \
|
|
|
+ if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
+ { \
|
|
|
+ StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
+ AssetQuery query; \
|
|
|
+ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
+ if (foundAssetcount != 0) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = query.mAssetList[0]; \
|
|
|
+ } \
|
|
|
+ else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
+ if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
+ { \
|
|
|
+ ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
+ privateShape->setShapeFile(_in); \
|
|
|
+ shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
+ shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
+ } \
|
|
|
+ m##name##Asset[index] = shapeAssetId; \
|
|
|
+ m##name##File[index] = _in; \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ m##name##Asset[index] = _in; \
|
|
|
+ m##name##File[index] = get##name##File(index); \
|
|
|
+ } \
|
|
|
+ }; \
|
|
|
+ \
|
|
|
+ inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
|
|
+ Resource<TSShape> get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \
|
|
|
+ AssetPtr<ShapeAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; } \
|
|
|
+ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\
|
|
|
+ StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; }
|
|
|
+
|
|
|
+#define DECLARE_SHAPEASSET_ARRAY_NET_REFACTOR(className, name, max, mask) \
|
|
|
+private: \
|
|
|
+ AssetPtr<ShapeAsset> m##name##Asset[max]; \
|
|
|
+ StringTableEntry m##name##File[max] = {StringTable->EmptyString() }; \
|
|
|
+public: \
|
|
|
+ void _set##name(StringTableEntry _in, const U32& index){ \
|
|
|
+ if (m##name##Asset[index].getAssetId() == _in) \
|
|
|
+ return; \
|
|
|
+ if(get##name##File(index) == _in) \
|
|
|
+ return; \
|
|
|
+ if (_in == NULL || _in == StringTable->EmptyString()) \
|
|
|
+ { \
|
|
|
+ m##name##Asset[index] = NULL; \
|
|
|
+ m##name##File[index] = ""; \
|
|
|
+ setMaskBits(mask); \
|
|
|
+ return; \
|
|
|
+ } \
|
|
|
+ if (!AssetDatabase.isDeclaredAsset(_in)) \
|
|
|
+ { \
|
|
|
+ StringTableEntry shapeAssetId = StringTable->EmptyString(); \
|
|
|
+ AssetQuery query; \
|
|
|
+ S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); \
|
|
|
+ if (foundAssetcount != 0) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = query.mAssetList[0]; \
|
|
|
+ } \
|
|
|
+ else if (Torque::FS::IsFile(_in) || (_in[0] == '$' || _in[0] == '#')) \
|
|
|
+ { \
|
|
|
+ shapeAssetId = ShapeAsset::getAssetIdByFilename(_in); \
|
|
|
+ if (shapeAssetId == ShapeAsset::smNoShapeAssetFallback) \
|
|
|
+ { \
|
|
|
+ ShapeAsset* privateShape = new ShapeAsset(); \
|
|
|
+ privateShape->setShapeFile(_in); \
|
|
|
+ shapeAssetId = AssetDatabase.addPrivateAsset(privateShape); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ Con::warnf("%s::%s: Could not find asset for: %s using fallback", #className, #name, _in); \
|
|
|
+ shapeAssetId = ShapeAsset::smNoShapeAssetFallback; \
|
|
|
+ } \
|
|
|
+ m##name##Asset[index] = shapeAssetId; \
|
|
|
+ m##name##File[index] = _in; \
|
|
|
+ } \
|
|
|
+ else \
|
|
|
+ { \
|
|
|
+ m##name##Asset[index] = _in; \
|
|
|
+ m##name##File[index] = get##name##File(index); \
|
|
|
+ } \
|
|
|
+ setMaskBits(mask); \
|
|
|
+ }; \
|
|
|
+ \
|
|
|
+ inline StringTableEntry _get##name##AssetId(const U32& index) const { return m##name##Asset[index].getAssetId(); } \
|
|
|
+ Resource<TSShape> get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \
|
|
|
+ AssetPtr<ShapeAsset> get##name##Asset(const U32& index) { return m##name##Asset[index]; } \
|
|
|
+ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast<className*>(obj)->_set##name(_getStringTable()->insert(data), dAtoi(index)); return false;}\
|
|
|
+ StringTableEntry get##name##File(const U32& idx) { return m##name##Asset[idx].notNull() ? m##name##Asset[idx]->getShapeFile() : ""; }
|
|
|
+
|
|
|
+#define INITPERSISTFIELD_SHAPEASSET_ARRAY_REFACTOR(name, arraySize, consoleClass, docs) \
|
|
|
+ addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));\
|
|
|
+ addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset docs.));
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// REFACTOR END
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
#endif
|