From fd7342668caed06ffa650e7731e78dbeb3c0edae Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 20 Jun 2025 15:58:20 +0100 Subject: [PATCH] streamline shape asset shape asset now has the same import "@" as image asset cut out extra filename parameters that arent needed refresh hopefully fixed --- Engine/source/T3D/assets/ShapeAsset.cpp | 173 +++++---- Engine/source/T3D/assets/ShapeAsset.h | 337 ++---------------- Engine/source/T3D/assets/assetImporter.cpp | 86 ++--- Engine/source/T3D/guiObjectView.cpp | 2 +- Engine/source/T3D/physics/physicsDebris.cpp | 2 +- Engine/source/T3D/physics/physicsShape.cpp | 2 +- Engine/source/T3D/shapeBase.cpp | 2 +- Engine/source/T3D/tsStatic.cpp | 2 +- .../source/gui/editor/guiShapeEdPreview.cpp | 2 +- Engine/source/gui/editor/inspector/group.cpp | 2 +- .../editor/inspector/variableInspector.cpp | 2 +- Engine/source/ts/assimp/assimpShapeLoader.cpp | 17 + .../source/ts/collada/colladaShapeLoader.cpp | 17 + Engine/source/ts/tsShapeConstruct.cpp | 2 +- Engine/source/ts/tsShapeConstruct.h | 2 +- 15 files changed, 185 insertions(+), 465 deletions(-) diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index decc7258a..c3ee4e89e 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -60,12 +60,20 @@ StringTableEntry ShapeAsset::smNoShapeAssetFallback = NULL; IMPLEMENT_CONOBJECT(ShapeAsset); -ConsoleType(assetIdString, TypeShapeAssetPtr, String, ASSET_ID_FIELD_PREFIX) + +//----------------------------------------------------------------------------- +// REFACTOR +//----------------------------------------------------------------------------- + +IMPLEMENT_STRUCT(AssetPtr, AssetPtrShapeAsset, , "") +END_IMPLEMENT_STRUCT + +ConsoleType(ShapeAssetPtr, TypeShapeAssetPtr, AssetPtr, ASSET_ID_FIELD_PREFIX) + ConsoleGetType(TypeShapeAssetPtr) { // Fetch asset Id. - //return *((StringTableEntry*)dptr); return (*((AssetPtr*)dptr)).getAssetId(); } @@ -77,17 +85,24 @@ ConsoleSetType(TypeShapeAssetPtr) // Yes, so fetch field value. const char* pFieldValue = argv[0]; - // Fetch asset Id. - StringTableEntry* assetId = (StringTableEntry*)(dptr); + // Fetch asset pointer. + AssetPtr* pAssetPtr = dynamic_cast*>((AssetPtrBase*)(dptr)); - // Update asset value. - *assetId = StringTable->insert(pFieldValue); + // Is the asset pointer the correct type? + if (pAssetPtr == NULL) + { + Con::warnf("(TypeShapeAssetPtr) - Failed to set asset Id '%d'.", pFieldValue); + return; + } + + // Set asset. + pAssetPtr->setAssetId(pFieldValue); return; } // Warn. - Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset."); + Con::warnf("(TypeShapeAssetPtr) - Cannot set multiple args to a single asset."); } //----------------------------------------------------------------------------- @@ -115,52 +130,6 @@ ConsoleSetType(TypeShapeAssetId) Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset."); } -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// REFACTOR -//----------------------------------------------------------------------------- - -IMPLEMENT_STRUCT(AssetPtr, AssetPtrShapeAsset, , "") -END_IMPLEMENT_STRUCT - -ConsoleType(ShapeAssetPtrRefactor, TypeShapeAssetPtrRefactor, AssetPtr, ASSET_ID_FIELD_PREFIX) - - -ConsoleGetType(TypeShapeAssetPtrRefactor) -{ - // Fetch asset Id. - return (*((AssetPtr*)dptr)).getAssetId(); -} - -ConsoleSetType(TypeShapeAssetPtrRefactor) -{ - // Was a single argument specified? - if (argc == 1) - { - // Yes, so fetch field value. - const char* pFieldValue = argv[0]; - - // Fetch asset pointer. - AssetPtr* pAssetPtr = dynamic_cast*>((AssetPtrBase*)(dptr)); - - // Is the asset pointer the correct type? - if (pAssetPtr == NULL) - { - Con::warnf("(TypeShapeAssetPtrRefactor) - Failed to set asset Id '%d'.", pFieldValue); - return; - } - - // Set asset. - pAssetPtr->setAssetId(pFieldValue); - - return; - } - - // Warn. - Con::warnf("(TypeShapeAssetPtrRefactor) - Cannot set multiple args to a single asset."); -} - //----------------------------------------------------------------------------- // REFACTOR END //----------------------------------------------------------------------------- @@ -176,15 +145,11 @@ const String ShapeAsset::mErrCodeStrings[] = ShapeAsset::ShapeAsset() { - mFileName = StringTable->EmptyString(); + mShapeFile = StringTable->EmptyString(); mConstructorFileName = StringTable->EmptyString(); - mFilePath = StringTable->EmptyString(); - mConstructorFilePath = StringTable->EmptyString(); mDiffuseImposterFileName = StringTable->EmptyString(); - mDiffuseImposterPath = StringTable->EmptyString(); mNormalImposterFileName = StringTable->EmptyString(); - mNormalImposterPath = StringTable->EmptyString(); mLoadedState = AssetErrCode::NotLoaded; @@ -217,7 +182,7 @@ void ShapeAsset::initPersistFields() // Call parent. Parent::initPersistFields(); - addProtectedField("fileName", TypeAssetLooseFilePath, Offset(mFileName, ShapeAsset), + addProtectedField("fileName", TypeAssetLooseFilePath, Offset(mShapeFile, ShapeAsset), &setShapeFile, &getShapeFile, "Path to the shape file we want to render"); addProtectedField("constuctorFileName", TypeAssetLooseFilePath, Offset(mConstructorFileName, ShapeAsset), &setShapeConstructorFile, &getShapeConstructorFile, "Path to the shape file we want to render"); @@ -225,7 +190,7 @@ void ShapeAsset::initPersistFields() addProtectedField("diffuseImposterFileName", TypeAssetLooseFilePath, Offset(mDiffuseImposterFileName, ShapeAsset), &setDiffuseImposterFile, &getDiffuseImposterFile, "Path to the diffuse imposter file we want to render"); addProtectedField("normalImposterFileName", TypeAssetLooseFilePath, Offset(mNormalImposterFileName, ShapeAsset), - &setNormalImposterFile, &getNormalImposterFile, "Path to the normal imposter file we want to render"); + &setNormalImposterFile, &getNormalImposterFilePath, "Path to the normal imposter file we want to render"); } @@ -248,29 +213,31 @@ void ShapeAsset::initializeAsset() // Call parent. Parent::initializeAsset(); - if (mFileName == StringTable->EmptyString()) + if (mShapeFile == StringTable->EmptyString()) return; ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged); //Ensure our path is expando'd if it isn't already - mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; + mShapeFile = getOwned() ? expandAssetFilePath(mShapeFile) : mShapeFile; - mConstructorFilePath = getOwned() ? expandAssetFilePath(mConstructorFileName) : mConstructorFilePath; - if (!Torque::FS::IsFile(mConstructorFilePath)) - Con::errorf("ShapeAsset::initializeAsset (%s) could not find %s!", getAssetName(), mConstructorFilePath); - mDiffuseImposterPath = getOwned() ? expandAssetFilePath(mDiffuseImposterFileName) : mDiffuseImposterFileName; - if (mDiffuseImposterPath == StringTable->EmptyString()) + mConstructorFileName = getOwned() ? expandAssetFilePath(mConstructorFileName) : mConstructorFileName; + if (!Torque::FS::IsFile(mConstructorFileName)) + Con::errorf("ShapeAsset::initializeAsset (%s) could not find %s!", getAssetName(), mConstructorFileName); + + + mDiffuseImposterFileName = getOwned() ? expandAssetFilePath(mDiffuseImposterFileName) : mDiffuseImposterFileName; + if (mDiffuseImposterFileName == StringTable->EmptyString()) { - String diffusePath = String(mFilePath) + "_imposter.dds"; - mDiffuseImposterPath = StringTable->insert(diffusePath.c_str()); + String diffusePath = String(mShapeFile) + "_imposter.dds"; + mDiffuseImposterFileName = StringTable->insert(diffusePath.c_str()); } - mNormalImposterPath = getOwned() ? expandAssetFilePath(mNormalImposterFileName) : mNormalImposterFileName; - if (mNormalImposterPath == StringTable->EmptyString()) + mNormalImposterFileName = getOwned() ? expandAssetFilePath(mNormalImposterFileName) : mNormalImposterFileName; + if (mNormalImposterFileName == StringTable->EmptyString()) { - String normalPath = String(mFilePath) + "_imposter_normals.dds"; - mNormalImposterPath = StringTable->insert(normalPath.c_str()); + String normalPath = String(mShapeFile) + "_imposter_normals.dds"; + mNormalImposterFileName = StringTable->insert(normalPath.c_str()); } } @@ -283,10 +250,10 @@ void ShapeAsset::setShapeFile(const char* pShapeFile) pShapeFile = StringTable->insert(pShapeFile, true); // Ignore no change, - if (pShapeFile == mFileName) + if (pShapeFile == mShapeFile) return; - mFileName = getOwned() ? expandAssetFilePath(pShapeFile) : pShapeFile; + mShapeFile = getOwned() ? expandAssetFilePath(pShapeFile) : pShapeFile; // Refresh the asset. refreshAsset(); @@ -348,7 +315,7 @@ void ShapeAsset::setNormalImposterFile(const char* pImageFile) void ShapeAsset::_onResourceChanged(const Torque::Path &path) { - if (path != Torque::Path(mFilePath) ) + if (path != Torque::Path(mShapeFile) ) return; refreshAsset(); @@ -397,17 +364,17 @@ U32 ShapeAsset::load() } } - mShape = ResourceManager::get().load(mFilePath); + mShape = ResourceManager::get().load(mShapeFile); if (!mShape) { - Con::errorf("ShapeAsset::loadShape : failed to load shape file %s (%s)!", getAssetName(), mFilePath); + Con::errorf("ShapeAsset::loadShape : failed to load shape file %s (%s)!", getAssetName(), mShapeFile); mLoadedState = BadFileReference; return mLoadedState; //if it failed to load, bail out } // Construct billboards if not done already if (GFXDevice::devicePresent()) - mShape->setupBillboardDetails(mFilePath, mDiffuseImposterPath, mNormalImposterPath); + mShape->setupBillboardDetails(mShapeFile, mDiffuseImposterFileName, mNormalImposterFileName); //If they exist, grab our imposters here and bind them to our shapeAsset @@ -467,8 +434,6 @@ U32 ShapeAsset::load() mLoadedState = Ok; - mChangeSignal.trigger(); - return mLoadedState; } @@ -536,13 +501,13 @@ StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName) AssetPtr temp = shapeAsset; if (temp.notNull()) { - if (temp->getShapePath() == fileName) + if (temp->getShapeFile() == fileName) { return shapeAsset; } else { - Torque::Path temp1 = temp->getShapePath(); + Torque::Path temp1 = temp->getShapeFile(); Torque::Path temp2 = fileName; if (temp1.getPath() == temp2.getPath() && temp1.getFileName() == temp2.getFileName()) @@ -606,16 +571,43 @@ void ShapeAsset::copyTo(SimObject* object) void ShapeAsset::onAssetRefresh(void) { - if (mFileName == StringTable->EmptyString()) + // Ignore if not yet added to the sim. + if (!isProperlyAdded()) return; - // Update. - if(!Platform::isFullPath(mFileName)) - mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; + if (mShapeFile == StringTable->EmptyString()) + return; + + // Call parent. + Parent::onAssetRefresh(); load(); } +void ShapeAsset::onTamlPreWrite(void) +{ + // Call parent. + Parent::onTamlPreWrite(); + + // ensure paths are collapsed. + mShapeFile = collapseAssetFilePath(mShapeFile); + mConstructorFileName = collapseAssetFilePath(mConstructorFileName); + mDiffuseImposterFileName = collapseAssetFilePath(mDiffuseImposterFileName); + mNormalImposterFileName = collapseAssetFilePath(mNormalImposterFileName); +} + +void ShapeAsset::onTamlPostWrite(void) +{ + // Call parent. + Parent::onTamlPostWrite(); + + // ensure paths are expanded. + mShapeFile = expandAssetFilePath(mShapeFile); + mConstructorFileName = expandAssetFilePath(mConstructorFileName); + mDiffuseImposterFileName = expandAssetFilePath(mDiffuseImposterFileName); + mNormalImposterFileName = expandAssetFilePath(mNormalImposterFileName); +} + void ShapeAsset::SplitSequencePathAndName(String& srcPath, String& srcName) { srcName = ""; @@ -705,7 +697,7 @@ const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overri delete imposterCap; delete shape; - String dumpPath = String(mFilePath) + ".png"; + String dumpPath = String(mShapeFile) + ".png"; char* returnBuffer = Con::getReturnBuffer(128); dSprintf(returnBuffer, 128, "%s", dumpPath.c_str()); @@ -749,14 +741,14 @@ DefineEngineMethod(ShapeAsset, getShapePath, const char*, (), , "Gets the shape's file path\n" "@return The filename of the shape file") { - return object->getShapeFilePath(); + return object->getShapeFile(); } DefineEngineMethod(ShapeAsset, getShapeConstructorFilePath, const char*, (), , "Gets the shape's constructor file.\n" "@return The filename of the shape constructor file") { - return object->getShapeConstructorFilePath(); + return object->getShapeConstructorFile(); } DefineEngineMethod(ShapeAsset, getStatusString, String, (), , "get status string")\ @@ -992,5 +984,4 @@ void GuiInspectorTypeShapeAssetId::consoleInit() ConsoleBaseType::getType(TypeShapeAssetId)->setInspectorFieldType("GuiInspectorTypeShapeAssetId"); } - #endif diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index 8a3d37ba5..5efd392b0 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -67,33 +67,6 @@ class ShapeAsset : public AssetBase typedef AssetBase Parent; typedef AssetPtr ConcreteAssetPtr; -protected: - StringTableEntry mFileName; - StringTableEntry mConstructorFileName; - StringTableEntry mFilePath; - StringTableEntry mConstructorFilePath; - Resource mShape; - - StringTableEntry mDiffuseImposterFileName; - StringTableEntry mDiffuseImposterPath; - - StringTableEntry mNormalImposterFileName; - StringTableEntry mNormalImposterPath; - - //Material assets we're dependent on and use - Vector mMaterialAssetIds; - Vector> mMaterialAssets; - - //Animation assets we're dependent on and use - Vector mAnimationAssetIds; - Vector> mAnimationAssets; - - typedef Signal ShapeAssetChanged; - ShapeAssetChanged mChangeSignal; - - typedef Signal 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 mMaterialAssetIds; + Vector> mMaterialAssets; + + //Animation assets we're dependent on and use + Vector mAnimationAssetIds; + Vector> mAnimationAssets; + + Resource 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 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> 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; }; + inline StringTableEntry getNormalImposterFilePath(void) const { return mNormalImposterFileName; }; static U32 getAssetByFilename(StringTableEntry fileName, AssetPtr* shapeAsset); @@ -195,25 +173,33 @@ 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(obj)->setShapeFile(data); return false; } static const char* getShapeFile(void* obj, const char* data) { return static_cast(obj)->getShapeFile(); } + static bool writeShapeFile(void* obj, StringTableEntry pFieldName) { return static_cast(obj)->getShapeFile() != StringTable->EmptyString(); } static bool setShapeConstructorFile(void* obj, const char* index, const char* data) { static_cast(obj)->setShapeConstructorFile(data); return false; } static const char* getShapeConstructorFile(void* obj, const char* data) { return static_cast(obj)->getShapeConstructorFile(); } static bool setDiffuseImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast(obj)->setDiffuseImposterFile(data); return false; } static const char* getDiffuseImposterFile(void* obj, const char* data) { return static_cast(obj)->getDiffuseImposterFile(); } + static bool setNormalImposterFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast(obj)->setNormalImposterFile(data); return false; } - static const char* getNormalImposterFile(void* obj, const char* data) { return static_cast(obj)->getNormalImposterFile(); } + static const char* getNormalImposterFilePath(void* obj, const char* data) { return static_cast(obj)->getNormalImposterFilePath(); } }; -DefineConsoleType(TypeShapeAssetPtr, S32) DefineConsoleType(TypeShapeAssetId, String) DECLARE_STRUCT(AssetPtr) -DefineConsoleType(TypeShapeAssetPtrRefactor, AssetPtr) +DefineConsoleType(TypeShapeAssetPtr, AssetPtr) #ifdef TORQUE_TOOLS //----------------------------------------------------------------------------- @@ -249,254 +235,9 @@ public: DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetId); static void consoleInit(); }; + #endif -#pragma region Singular Asset Macros - -#define DECLARE_SHAPEASSET(className,name,changeFunc) public: \ - Resourcem##name;\ - StringTableEntry m##name##Name; \ - StringTableEntry m##name##AssetId;\ - AssetPtr 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 & get##name##Asset() const { return m##name##Asset; }\ - void set##name##Asset(const AssetPtr &_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 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 - -#pragma endregion - -#pragma region Arrayed Asset Macros - -#define DECLARE_SHAPEASSET_ARRAY(className,name,max,changeFunc) public: \ - static const U32 sm##name##Count = max;\ - Resourcem##name[max];\ - StringTableEntry m##name##Name[max]; \ - StringTableEntry m##name##AssetId[max];\ - AssetPtr 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 & get##name##Asset(const U32& index) const { return m##name##Asset[index]; }\ - void set##name##Asset(const AssetPtr &_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 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 endregion - - //----------------------------------------------------------------------------- // REFACTOR //----------------------------------------------------------------------------- @@ -557,7 +298,7 @@ public: Resource get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \ AssetPtr get##name##Asset(void) { return m##name##Asset; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data)); return false; } \ - StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapePath() : ""; } + StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; } #define DECLARE_SHAPEASSET_NET_REFACTOR(className, name, mask) \ private: \ @@ -615,10 +356,10 @@ public: Resource get##name() { if (m##name##Asset.notNull()) return m##name##Asset->getShapeResource(); else return ResourceManager::get().load( "" ); } \ AssetPtr get##name##Asset(void) { return m##name##Asset; } \ static bool _set##name##Data(void* obj, const char* index, const char* data) { static_cast(obj)->_set##name(_getStringTable()->insert(data)); return false; } \ - StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapePath() : ""; } + StringTableEntry get##name##File() { return m##name##Asset.notNull() ? m##name##Asset->getShapeFile() : ""; } #define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \ - addProtectedField(assetText(name, Asset), TypeShapeAssetPtrRefactor, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset 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.)); @@ -676,7 +417,7 @@ public: Resource get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \ AssetPtr 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(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]->getShapePath() : ""; } + 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: \ @@ -734,10 +475,10 @@ public: Resource get##name(const U32& index) { if (m##name##Asset[index].notNull()) return m##name##Asset[index]->getShapeResource(); else return ResourceManager::get().load( "" ); } \ AssetPtr 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(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]->getShapePath() : ""; } + 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), TypeShapeAssetPtrRefactor, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, arraySize, assetDoc(name, asset 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 diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 726f490de..b6ce8b535 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -3035,31 +3035,15 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str()); - String shapeFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension(); + String shapeFileName = "@" + assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension(); String constructorFileName = assetItem->filePath.getFileName() + "." TORQUE_SCRIPT_EXTENSION; String assetPath = targetPath + "/" + shapeFileName; String constructorPath = targetPath + "/" + constructorFileName; + constructorFileName = "@" + constructorFileName; String tamlPath = targetPath + "/" + assetName + ".asset.taml"; String originalPath = assetItem->filePath.getFullPath().c_str(); String originalConstructorPath = assetItem->filePath.getPath() + "/" + constructorFileName; - char qualifiedFromFile[2048]; - char qualifiedToFile[2048]; - char qualifiedFromCSFile[2048]; - char qualifiedToCSFile[2048]; - -#ifndef TORQUE_SECURE_VFS - Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile)); - Platform::makeFullPathName(assetPath.c_str(), qualifiedToFile, sizeof(qualifiedToFile)); - Platform::makeFullPathName(originalConstructorPath.c_str(), qualifiedFromCSFile, sizeof(qualifiedFromCSFile)); - Platform::makeFullPathName(constructorPath.c_str(), qualifiedToCSFile, sizeof(qualifiedToCSFile)); -#else - dStrcpy(qualifiedFromFile, originalPath.c_str(), sizeof(qualifiedFromFile)); - dStrcpy(qualifiedToFile, assetPath.c_str(), sizeof(qualifiedToFile)); - dStrcpy(qualifiedFromCSFile, originalConstructorPath.c_str(), sizeof(qualifiedFromCSFile)); - dStrcpy(qualifiedToCSFile, constructorPath.c_str(), sizeof(qualifiedToCSFile)); -#endif - newAsset->setAssetName(assetName); newAsset->setShapeFile(shapeFileName.c_str()); newAsset->setShapeConstructorFile(constructorFileName.c_str()); @@ -3076,9 +3060,9 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) //If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original //file path for reimporting support later - if (!isReimport && String::compare(qualifiedFromFile, qualifiedToFile) && Torque::FS::IsFile(qualifiedFromFile)) + if (!isReimport && Torque::FS::IsFile(originalPath)) { - newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); + newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, originalPath.c_str()); } //iterate through and write out the material maps dependencies @@ -3118,8 +3102,8 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) if (Con::getBoolVariable("$TSLastDetail::dumpImposters", false)) { - String imposterPath = assetItem->assetName + "_imposter.png"; - String normalsPath = assetItem->assetName + "_imposter_normals.png"; + String imposterPath = "@" + assetItem->assetName + "_imposter.png"; + String normalsPath = "@" + assetItem->assetName + "_imposter_normals.png"; newAsset->setDiffuseImposterFile(imposterPath.c_str()); newAsset->setNormalImposterFile(normalsPath.c_str()); @@ -3138,67 +3122,37 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) bool makeNewConstructor = true; if (!isReimport) { - bool isInPlace = !String::compare(qualifiedFromFile, qualifiedToFile); - - if (!isInPlace && !Torque::FS::CopyFile(qualifiedFromFile, qualifiedToFile, !isReimport)) + //We're doing an in-place import, so double check we've already got a constructor file in the expected spot + if (Torque::FS::IsFile(constructorPath)) { - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromFile); + //Yup, found it, we're good to go + makeNewConstructor = false; + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constructorPath.c_str()); activityLog.push_back(importLogBuffer); - return ""; - } - - if (!isInPlace) - { - if (Torque::FS::IsFile(qualifiedFromCSFile)) - { - if (!Torque::FS::CopyFile(qualifiedFromCSFile, qualifiedToCSFile, !isReimport)) - { - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromCSFile); - activityLog.push_back(importLogBuffer); - } - else - { - //We successfully copied the original constructor file, so no extra work required - makeNewConstructor = false; - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Successfully copied original TSShape Constructor file %s", qualifiedFromCSFile); - activityLog.push_back(importLogBuffer); - } - } } else { - //We're doing an in-place import, so double check we've already got a constructor file in the expected spot - if (Torque::FS::IsFile(qualifiedFromCSFile)) + //Didn't work, but it's possible it's using the old .cs extension when our extension variable is set to something else, so check that one as well just to be sure + Torque::Path constrFilePath = constructorPath; + constrFilePath.setExtension("cs"); + + if (Torque::FS::IsFile(constrFilePath.getFullPath().c_str())) { //Yup, found it, we're good to go makeNewConstructor = false; - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", qualifiedFromCSFile); + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constrFilePath.getFullPath().c_str()); activityLog.push_back(importLogBuffer); } - else - { - //Didn't work, but it's possible it's using the old .cs extension when our extension variable is set to something else, so check that one as well just to be sure - Torque::Path constrFilePath = qualifiedFromCSFile; - constrFilePath.setExtension("cs"); - - if (Torque::FS::IsFile(constrFilePath.getFullPath().c_str())) - { - //Yup, found it, we're good to go - makeNewConstructor = false; - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constrFilePath.getFullPath().c_str()); - activityLog.push_back(importLogBuffer); - } - } } } if (makeNewConstructor) { - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", qualifiedToCSFile); + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", constructorPath.c_str()); activityLog.push_back(importLogBuffer); //find/create shape constructor - TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructorByFilename(Torque::Path(qualifiedToFile).getFullPath()); + TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructorByFilename(Torque::Path(constructorPath).getFullPath()); if (constructor == nullptr) { String fullAssetName = assetItem->moduleName + ":" + assetItem->assetName; @@ -3302,7 +3256,7 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) PersistenceManager* constructorPersist = new PersistenceManager(); constructorPersist->registerObject(); - constructorPersist->setDirty(constructor, qualifiedToCSFile); + constructorPersist->setDirty(constructor, constructorPath); if (!constructorPersist->saveDirtyObject(constructor)) { diff --git a/Engine/source/T3D/guiObjectView.cpp b/Engine/source/T3D/guiObjectView.cpp index 911e52e60..c086c85ac 100644 --- a/Engine/source/T3D/guiObjectView.cpp +++ b/Engine/source/T3D/guiObjectView.cpp @@ -357,7 +357,7 @@ bool GuiObjectView::setObjectModel( const String& modelName ) mModelInstance->reSkin( mSkinName ); TSMaterialList* pMatList = mModelInstance->getMaterialList(); - pMatList->setTextureLookupPath(mModelAsset->getShapeFileName()); + pMatList->setTextureLookupPath(mModelAsset->getShapeFile()); mModelInstance->initMaterialList(); // Initialize camera values. diff --git a/Engine/source/T3D/physics/physicsDebris.cpp b/Engine/source/T3D/physics/physicsDebris.cpp index 7f77f5d0c..35fee7a34 100644 --- a/Engine/source/T3D/physics/physicsDebris.cpp +++ b/Engine/source/T3D/physics/physicsDebris.cpp @@ -119,7 +119,7 @@ void PhysicsDebrisData::initPersistFields() addGroup( "Shapes" ); INITPERSISTFIELD_SHAPEASSET_REFACTOR(Shape, PhysicsDebrisData, "@brief Shape to use with this debris.\n\n" - "Compatable with Live-Asset Reloading."); + "Compatable with Live-Asset Reloading."); endGroup( "Shapes" ); diff --git a/Engine/source/T3D/physics/physicsShape.cpp b/Engine/source/T3D/physics/physicsShape.cpp index 09e86c530..55e488009 100644 --- a/Engine/source/T3D/physics/physicsShape.cpp +++ b/Engine/source/T3D/physics/physicsShape.cpp @@ -247,7 +247,7 @@ void PhysicsShapeData::_onResourceChanged( const Torque::Path &path ) { return; } - if ( path != Path(mShapeAsset->getShapeFilePath()) ) + if ( path != Path(mShapeAsset->getShapeFile()) ) return; _setShape(_getShapeAssetId()); diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index 8e1f19013..af078b2e2 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -363,7 +363,7 @@ bool ShapeBaseData::preload(bool server, String &errorStr) { Con::printf("Validation required for shape asset: %s", mShapeAsset.getAssetId()); - Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(mShapeAsset->getShapePath()); + Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(mShapeAsset->getShapeFile()); if (!fileRef) { diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index ad41f08c6..eccfee97e 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -1587,7 +1587,7 @@ void TSStatic::updateMaterials() String path; if (mShapeAsset->isAssetValid()) - path = mShapeAsset->getShapeFileName(); + path = mShapeAsset->getShapeFile(); else path = mShapeFile; diff --git a/Engine/source/gui/editor/guiShapeEdPreview.cpp b/Engine/source/gui/editor/guiShapeEdPreview.cpp index 1724db214..ff1c8a884 100644 --- a/Engine/source/gui/editor/guiShapeEdPreview.cpp +++ b/Engine/source/gui/editor/guiShapeEdPreview.cpp @@ -420,7 +420,7 @@ bool GuiShapeEdPreview::setObjectShapeAsset(const char* assetId) if (assetType == StringTable->insert("ShapeAsset")) { ShapeAsset* asset = AssetDatabase.acquireAsset(id); - modelName = asset->getShapeFilePath(); + modelName = asset->getShapeFile(); AssetDatabase.releaseAsset(id); } else if (assetType == StringTable->insert("ShapeAnimationAsset")) diff --git a/Engine/source/gui/editor/inspector/group.cpp b/Engine/source/gui/editor/inspector/group.cpp index 6bd243d60..13953ead5 100644 --- a/Engine/source/gui/editor/inspector/group.cpp +++ b/Engine/source/gui/editor/inspector/group.cpp @@ -665,7 +665,7 @@ void GuiInspectorGroup::addInspectorField(StringTableEntry name, StringTableEntr else if (typeName == StringTable->insert("image")) fieldType = TypeImageAssetPtr; else if (typeName == StringTable->insert("shape")) - fieldType = TypeShapeAssetId; + fieldType = TypeShapeAssetPtr; else if (typeName == StringTable->insert("sound")) fieldType = TypeSoundAssetId; else if (typeName == StringTable->insert("bool")) diff --git a/Engine/source/gui/editor/inspector/variableInspector.cpp b/Engine/source/gui/editor/inspector/variableInspector.cpp index 41a165d32..fc78e76b3 100644 --- a/Engine/source/gui/editor/inspector/variableInspector.cpp +++ b/Engine/source/gui/editor/inspector/variableInspector.cpp @@ -205,7 +205,7 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c else if (newField->mFieldTypeName == StringTable->insert("image")) fieldTypeMask = TypeImageAssetPtr; else if (newField->mFieldTypeName == StringTable->insert("shape")) - fieldTypeMask = TypeShapeAssetId; + fieldTypeMask = TypeShapeAssetPtr; else if (newField->mFieldTypeName == StringTable->insert("bool")) fieldTypeMask = TypeBool; else if (newField->mFieldTypeName == StringTable->insert("object")) diff --git a/Engine/source/ts/assimp/assimpShapeLoader.cpp b/Engine/source/ts/assimp/assimpShapeLoader.cpp index c261f11cd..a8c5e0079 100644 --- a/Engine/source/ts/assimp/assimpShapeLoader.cpp +++ b/Engine/source/ts/assimp/assimpShapeLoader.cpp @@ -993,6 +993,23 @@ TSShape* assimpLoadShape(const Torque::Path &path) tss->write(&dtsStream); } + Torque::Path dsqPath(cachedPath); + dsqPath.setExtension("dsq"); + FileStream animOutStream; + for (S32 i = 0; i < tss->sequences.size(); i++) + { + const String& seqName = tss->getName(tss->sequences[i].nameIndex); + Con::printf("Writing DSQ Animation File for sequence '%s'", seqName.c_str()); + + dsqPath.setFileName(cachedPath.getFileName() + "_" + seqName); + if (animOutStream.open(dsqPath.getFullPath(), Torque::FS::File::Write)) + { + tss->exportSequence(&animOutStream, tss->sequences[i], false); + animOutStream.close(); + } + + } + loader.updateMaterialsScript(path); } loader.releaseImport(); diff --git a/Engine/source/ts/collada/colladaShapeLoader.cpp b/Engine/source/ts/collada/colladaShapeLoader.cpp index 817ca3a6e..f9bc763ba 100644 --- a/Engine/source/ts/collada/colladaShapeLoader.cpp +++ b/Engine/source/ts/collada/colladaShapeLoader.cpp @@ -737,6 +737,23 @@ TSShape* loadColladaShape(const Torque::Path &path) tss->write(&dtsStream); } + Torque::Path dsqPath(cachedPath); + dsqPath.setExtension("dsq"); + FileStream animOutStream; + for (S32 i = 0; i < tss->sequences.size(); i++) + { + const String& seqName = tss->getName(tss->sequences[i].nameIndex); + Con::printf("Writing DSQ Animation File for sequence '%s'", seqName.c_str()); + + dsqPath.setFileName(cachedPath.getFileName() + "_" + seqName); + if (animOutStream.open(dsqPath.getFullPath(), Torque::FS::File::Write)) + { + tss->exportSequence(&animOutStream, tss->sequences[i], false); + animOutStream.close(); + } + + } + #endif // DAE2DTS_TOOL // Add collada materials to materials.tscript diff --git a/Engine/source/ts/tsShapeConstruct.cpp b/Engine/source/ts/tsShapeConstruct.cpp index 65eafc637..f3f540f8a 100644 --- a/Engine/source/ts/tsShapeConstruct.cpp +++ b/Engine/source/ts/tsShapeConstruct.cpp @@ -2138,7 +2138,7 @@ DefineTSShapeConstructorMethod(addSequence, bool, if (assetType == StringTable->insert("ShapeAsset")) { ShapeAsset* asset = AssetDatabase.acquireAsset(assetId); - srcPath = asset->getShapeFilePath(); + srcPath = asset->getShapeFile(); AssetDatabase.releaseAsset(assetId); } else if (assetType == StringTable->insert("ShapeAnimationAsset")) diff --git a/Engine/source/ts/tsShapeConstruct.h b/Engine/source/ts/tsShapeConstruct.h index df04078de..f4f8dfbff 100644 --- a/Engine/source/ts/tsShapeConstruct.h +++ b/Engine/source/ts/tsShapeConstruct.h @@ -236,7 +236,7 @@ public: StringTableEntry getShapePath() const { if (mShapeAsset.notNull()) - return mShapeAsset->getShapeFilePath(); + return mShapeAsset->getShapeFile(); else return StringTable->EmptyString(); }