소스 검색

fix asset refresh on materialAssets

marauder2k7 6 달 전
부모
커밋
fc30d178af
3개의 변경된 파일13개의 추가작업 그리고 31개의 파일을 삭제
  1. 2 3
      Engine/source/T3D/assets/ImageAsset.cpp
  2. 1 0
      Engine/source/T3D/assets/ImageAsset.h
  3. 10 28
      Engine/source/T3D/assets/MaterialAsset.cpp

+ 2 - 3
Engine/source/T3D/assets/ImageAsset.cpp

@@ -334,7 +334,6 @@ void ImageAsset::onAssetRefresh(void)
    // Call parent.
    Parent::onAssetRefresh();
 
-   //mLoadedState = NotLoaded;
 }
 
 //------------------------------------------------------------------------------
@@ -577,7 +576,7 @@ void ImageAsset::onTamlPreWrite(void)
       return;
 
    // Ensure the image-file is collapsed.
-   mImageFile = getOwned() ? collapseAssetFilePath(mImageFile) : mImageFile;
+   mImageFile = collapseAssetFilePath(mImageFile);
 }
 
 void ImageAsset::onTamlPostWrite(void)
@@ -589,7 +588,7 @@ void ImageAsset::onTamlPostWrite(void)
       return;
 
    // Ensure the image-file is expanded.
-   mImageFile = getOwned() ? expandAssetFilePath(mImageFile) : mImageFile;
+   mImageFile = expandAssetFilePath(mImageFile);
 }
 
 const char* ImageAsset::getImageInfo()

+ 1 - 0
Engine/source/T3D/assets/ImageAsset.h

@@ -165,6 +165,7 @@ public:
 
    void                    setImageFile(StringTableEntry pImageFile);
    inline StringTableEntry getImageFile(void) const { return mImageFile; };
+   inline StringTableEntry getRelativeImageFile(void) const { return collapseAssetFilePath(mImageFile); };
 
    void                    setGenMips(const bool pGenMips);
    inline bool             getGenMips(void) const { return mUseMips; };

+ 10 - 28
Engine/source/T3D/assets/MaterialAsset.cpp

@@ -211,39 +211,21 @@ void MaterialAsset::initializeAsset()
 
 void MaterialAsset::onAssetRefresh()
 {
-   mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
-
-   if (mMatDefinitionName == StringTable->EmptyString())
-   {
-      mLoadedState = Failed;
+   // Ignore if not yet added to the sim.
+   if (!isProperlyAdded())
       return;
-   }
 
-   if (Con::isScriptFile(mScriptPath))
-   {
-      //Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
-      //But that definition, whatever it is, is the 'correct' one, so we enable the Replace Existing behavior
-      //when the engine encounters a named object conflict.
-      String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
-      Con::setVariable("$Con::redefineBehavior", "replaceExisting");
-
-      if (Con::executeFile(mScriptPath, false, false))
-         mLoadedState = ScriptLoaded;
-      else
-         mLoadedState = Failed;
+   // Call parent.
+   Parent::onAssetRefresh();
 
-      //And now that we've executed, switch back to the prior behavior
-      Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
+   if (mMaterialDefinition)
+   {
+      mMaterialDefinition->flush();
+      mMaterialDefinition->reload();
    }
-
-   load();
-   AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
-   // Iterate all dependencies.
-   while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
+   else
    {
-      StringTableEntry assetId = assetDependenciesItr->value;
-      AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
-      dependent->refreshAsset();
+      load();
    }
 }