From 3ace31c68ca096e7e9e6dea7bf1768c34424a923 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 6 Apr 2024 14:48:22 -0500 Subject: [PATCH 1/4] crashfix work for hot-editing shape assets tied to tsstatics --- Engine/source/T3D/assets/ImageAsset.h | 2 +- Engine/source/T3D/assets/LevelAsset.h | 2 +- Engine/source/T3D/assets/MaterialAsset.h | 2 +- Engine/source/T3D/assets/ShapeAsset.cpp | 5 +++-- Engine/source/T3D/assets/ShapeAsset.h | 2 +- Engine/source/T3D/assets/SoundAsset.h | 2 +- Engine/source/T3D/assets/TerrainAsset.h | 2 +- Engine/source/T3D/assets/TerrainMaterialAsset.h | 2 +- Engine/source/T3D/tsStatic.cpp | 5 ++++- Engine/source/assets/assetBase.h | 2 +- 10 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index 6849a5a87..03bbaa556 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -151,7 +151,7 @@ public: static U32 getAssetById(StringTableEntry assetId, AssetPtr* imageAsset); static U32 getAssetById(String assetId, AssetPtr* imageAsset) { return getAssetById(assetId.c_str(), imageAsset); }; - U32 load(); + U32 load() override; protected: void initializeAsset(void) override; diff --git a/Engine/source/T3D/assets/LevelAsset.h b/Engine/source/T3D/assets/LevelAsset.h index b58aca4ba..11cedd7d6 100644 --- a/Engine/source/T3D/assets/LevelAsset.h +++ b/Engine/source/T3D/assets/LevelAsset.h @@ -111,7 +111,7 @@ public: void setBakedSceneFile(const char* pBakedSceneFile); inline StringTableEntry getBakedSceneFile(void) const { return mBakedSceneFile; }; - SimObjectId load(); + U32 load() override { return Ok; }; protected: static bool setLevelFile(void *obj, const char *index, const char *data) { static_cast(obj)->setLevelFile(data); return false; } diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index 6c4d8943f..4a9808fc8 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -104,7 +104,7 @@ public: static void initPersistFields(); void copyTo(SimObject* object) override; - U32 load(); + U32 load() override; StringTableEntry getMaterialDefinitionName() { return mMatDefinitionName; } SimObjectPtr getMaterialDefinition() { return mMaterialDefinition; } diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index 4197b0100..9be189324 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -304,8 +304,6 @@ void ShapeAsset::_onResourceChanged(const Torque::Path &path) return; refreshAsset(); - - onAssetRefresh(); } U32 ShapeAsset::load() @@ -534,6 +532,9 @@ void ShapeAsset::onAssetRefresh(void) // Update. if(!Platform::isFullPath(mFileName)) mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; + + load(); + //onAssetRefresh(); } void ShapeAsset::SplitSequencePathAndName(String& srcPath, String& srcName) diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index 650c6bdb9..afa39ca57 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -132,7 +132,7 @@ public: /// Declare Console Object. DECLARE_CONOBJECT(ShapeAsset); - U32 load(); + U32 load() override; TSShape* getShape() { return mShape; } diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index e9f851f7b..f867e0e4f 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -156,7 +156,7 @@ public: DECLARE_CONOBJECT(SoundAsset); static bool _setSoundFile(void* object, const char* index, const char* data); - U32 load(); + U32 load() override; inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; }; SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; } SFXPlayList* getSfxPlaylist() { return &mPlaylist; } diff --git a/Engine/source/T3D/assets/TerrainAsset.h b/Engine/source/T3D/assets/TerrainAsset.h index 09800c37e..2f5f93520 100644 --- a/Engine/source/T3D/assets/TerrainAsset.h +++ b/Engine/source/T3D/assets/TerrainAsset.h @@ -82,7 +82,7 @@ public: inline Resource getTerrainResource(void) const { return mTerrainFile; }; - U32 load(); + U32 load() override; static bool getAssetByFilename(StringTableEntry fileName, AssetPtr* shapeAsset); static StringTableEntry getAssetIdByFilename(StringTableEntry fileName); diff --git a/Engine/source/T3D/assets/TerrainMaterialAsset.h b/Engine/source/T3D/assets/TerrainMaterialAsset.h index b5c966e54..7a02b1d08 100644 --- a/Engine/source/T3D/assets/TerrainMaterialAsset.h +++ b/Engine/source/T3D/assets/TerrainMaterialAsset.h @@ -89,7 +89,7 @@ public: static void initPersistFields(); void copyTo(SimObject* object) override; - U32 load(); + U32 load() override; StringTableEntry getMaterialDefinitionName() { return mMatDefinitionName; } SimObjectPtr getMaterialDefinition() { return mMaterialDefinition; } diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index b7cd9b664..17d674a96 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -389,7 +389,7 @@ bool TSStatic::_createShape() SAFE_DELETE(mPhysicsRep); SAFE_DELETE(mShapeInstance); mAmbientThread = NULL; - mShape = NULL; + //mShape = NULL; U32 assetStatus = ShapeAsset::getAssetErrCode(mShapeAsset); if (assetStatus == AssetBase::Ok || assetStatus == AssetBase::UsingFallback) @@ -619,6 +619,9 @@ void TSStatic::onShapeChanged() { _createShape(); _updateShouldTick(); + + if (isServerObject()) + setMaskBits(AdvancedStaticOptionsMask); } void TSStatic::setSkinName(const char* name) diff --git a/Engine/source/assets/assetBase.h b/Engine/source/assets/assetBase.h index 0877fc321..fe14c7729 100644 --- a/Engine/source/assets/assetBase.h +++ b/Engine/source/assets/assetBase.h @@ -91,7 +91,7 @@ public: return mErrCodeStrings[errCode]; }; U32 getStatus() { return mLoadedState; }; - U32 load() { return NotLoaded; }; + virtual U32 load() { return NotLoaded; }; AssetBase(); virtual ~AssetBase(); From 5ff83138cf50de06b6558ca2e0856b3611fbce8d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 6 Apr 2024 16:39:31 -0500 Subject: [PATCH 2/4] need to set state to ok post-load and pre-changesignal callback --- Engine/source/T3D/assets/ShapeAsset.cpp | 4 ++-- Engine/source/T3D/tsStatic.cpp | 9 --------- Engine/source/T3D/tsStatic.h | 1 - 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index 9be189324..8945335a7 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -417,9 +417,10 @@ U32 ShapeAsset::load() } } + mLoadedState = Ok; + mChangeSignal.trigger(); - mLoadedState = Ok; return mLoadedState; } @@ -534,7 +535,6 @@ void ShapeAsset::onAssetRefresh(void) mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath; load(); - //onAssetRefresh(); } void ShapeAsset::SplitSequencePathAndName(String& srcPath, String& srcName) diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 17d674a96..a33bd5029 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -606,15 +606,6 @@ void TSStatic::onRemove() Parent::onRemove(); } -void TSStatic::_onResourceChanged(const Torque::Path& path) -{ - if (path != Path(mShapeName)) - return; - - _createShape(); - _updateShouldTick(); -} - void TSStatic::onShapeChanged() { _createShape(); diff --git a/Engine/source/T3D/tsStatic.h b/Engine/source/T3D/tsStatic.h index d5c783c0b..d0c9f6c46 100644 --- a/Engine/source/T3D/tsStatic.h +++ b/Engine/source/T3D/tsStatic.h @@ -169,7 +169,6 @@ protected: void _renderNormals(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat); - void _onResourceChanged(const Torque::Path& path); void onShapeChanged(); // ProcessObject From 40d38cc1ec5623415a807e09a357ef5239062241 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 6 Apr 2024 16:48:02 -0500 Subject: [PATCH 3/4] uneeeded --- Engine/source/T3D/tsStatic.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index a33bd5029..022cffa93 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -610,9 +610,6 @@ void TSStatic::onShapeChanged() { _createShape(); _updateShouldTick(); - - if (isServerObject()) - setMaskBits(AdvancedStaticOptionsMask); } void TSStatic::setSkinName(const char* name) From 00bdc913b0c74ea08d05d66d43a4d4b5d4e8bd26 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 6 Apr 2024 17:14:56 -0500 Subject: [PATCH 4/4] onAssetRefresh(); already chains. no need to call that again --- Engine/source/T3D/assets/ImageAsset.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index 3c5786d06..b51327c4e 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -318,8 +318,6 @@ void ImageAsset::_onResourceChanged(const Torque::Path& path) return; refreshAsset(); - - onAssetRefresh(); } void ImageAsset::setImageFileName(const char* pScriptFile)