瀏覽代碼

clean up redundant loads, shift first load to getResource methods for sound and shape.
still need to properly sort image

AzaezelX 1 年之前
父節點
當前提交
a8d640e311

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

@@ -301,13 +301,11 @@ void ImageAsset::initializeAsset()
    ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
 
    mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
-   //loadImage();
 }
 
 void ImageAsset::onAssetRefresh()
 {
    mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
-   //loadImage();
 }
 
 void ImageAsset::_onResourceChanged(const Torque::Path& path)
@@ -317,7 +315,6 @@ void ImageAsset::_onResourceChanged(const Torque::Path& path)
 
    refreshAsset();
 
-   //loadImage();
    onAssetRefresh();
 }
 

+ 0 - 8
Engine/source/T3D/assets/ShapeAsset.cpp

@@ -224,8 +224,6 @@ void ShapeAsset::initializeAsset()
       String normalPath = String(mFilePath) + "_imposter_normals.dds";
       mNormalImposterPath = StringTable->insert(normalPath.c_str());
    }
-
-   //loadShape();
 }
 
 void ShapeAsset::setShapeFile(const char* pShapeFile)
@@ -461,7 +459,6 @@ U32 ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsse
    {
       //acquire and bind the asset, and return it out
       shapeAsset->setAssetId(query.mAssetList[0]);
-      (*shapeAsset)->loadShape();
       return (*shapeAsset)->mLoadedState;
    }
 }
@@ -494,7 +491,6 @@ U32 ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* sha
 
    if (shapeAsset->notNull())
    {
-      (*shapeAsset)->loadShape();
       return (*shapeAsset)->mLoadedState;
    }
    else
@@ -504,7 +500,6 @@ U32 ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* sha
 
       if (shapeAsset->isNull())
       {
-         (*shapeAsset)->loadShape();
          //Well that's bad, loading the fallback failed.
          Con::warnf("ShapeAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId);
          return AssetErrCode::Failed;
@@ -513,7 +508,6 @@ U32 ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* sha
       //handle noshape not being loaded itself
       if ((*shapeAsset)->mLoadedState == BadFileReference)
       {
-         (*shapeAsset)->loadShape();
          Con::warnf("ShapeAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId);
          return AssetErrCode::BadFileReference;
       }
@@ -540,8 +534,6 @@ void ShapeAsset::onAssetRefresh(void)
    // Update.
    if(!Platform::isFullPath(mFileName))
       mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
-
-   loadShape();
 }
 
 void ShapeAsset::SplitSequencePathAndName(String& srcPath, String& srcName)

+ 1 - 1
Engine/source/T3D/assets/ShapeAsset.h

@@ -136,7 +136,7 @@ public:
 
    TSShape* getShape() { return mShape; }
 
-   Resource<TSShape> getShapeResource() { return mShape; }
+   Resource<TSShape> getShapeResource() { loadShape(); return mShape; }
 
    void SplitSequencePathAndName(String& srcPath, String& srcName);
    StringTableEntry getShapeFileName() { return mFileName; }

+ 3 - 3
Engine/source/T3D/assets/SoundAsset.cpp

@@ -198,7 +198,7 @@ void SoundAsset::initializeAsset(void)
       return;
 
    mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath;
-   loadSound();
+   //loadSound();
 }
 
 void SoundAsset::_onResourceChanged(const Torque::Path &path)
@@ -208,7 +208,7 @@ void SoundAsset::_onResourceChanged(const Torque::Path &path)
 
    refreshAsset();
 
-   loadSound();
+   //loadSound();
 }
 
 void SoundAsset::onAssetRefresh(void)
@@ -218,7 +218,7 @@ void SoundAsset::onAssetRefresh(void)
 
    //Update
    mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath;
-   loadSound();
+   //loadSound();
 }
 
 bool SoundAsset::loadSound()

+ 1 - 1
Engine/source/T3D/assets/SoundAsset.h

@@ -132,7 +132,7 @@ public:
    virtual void copyTo(SimObject* object);
 
    //SFXResource* getSound() { return mSoundResource; }
-   Resource<SFXResource> getSoundResource() { return mSFXProfile.getResource(); }
+   Resource<SFXResource> getSoundResource() { loadSound(); return mSFXProfile.getResource(); }
 
    /// Declare Console Object.
    DECLARE_CONOBJECT(SoundAsset);