diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index c3a2db842..af03cfe2d 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -207,8 +207,7 @@ U32 ImageAsset::getAssetByFilename(StringTableEntry fileName, AssetPtrsetAssetId(query.mAssetList[0]); - (*imageAsset)->loadImage(); - return (*imageAsset)->mLoadedState; + return (*imageAsset)->load(); } } @@ -240,8 +239,7 @@ U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr* ima if (imageAsset->notNull()) { - (*imageAsset)->loadImage(); - return (*imageAsset)->mLoadedState; + return (*imageAsset)->load(); } else { @@ -253,7 +251,6 @@ U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr* ima //handle fallback not being loaded itself if ((*imageAsset)->mLoadedState == BadFileReference) { - (*imageAsset)->loadImage(); Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId); return AssetErrCode::BadFileReference; } @@ -272,25 +269,26 @@ void ImageAsset::copyTo(SimObject* object) Parent::copyTo(object); } -void ImageAsset::loadImage() +U32 ImageAsset::load() { - if (mLoadedState == AssetErrCode::Ok) return; + if (mLoadedState == AssetErrCode::Ok) return mLoadedState; if (mImagePath) { if (!Torque::FS::IsFile(mImagePath)) { Con::errorf("ImageAsset::initializeAsset: Attempted to load file %s but it was not valid!", mImageFileName); mLoadedState = BadFileReference; - return; + return mLoadedState; } mLoadedState = Ok; mIsValidImage = true; - return; + return mLoadedState; } mLoadedState = BadFileReference; mIsValidImage = false; + return mLoadedState; } void ImageAsset::initializeAsset() @@ -327,11 +325,6 @@ void ImageAsset::setImageFileName(const char* pScriptFile) refreshAsset(); } -const GBitmap& ImageAsset::getImage() -{ - return GBitmap(); //TODO fix this -} - GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile) { if (mResourceMap.contains(requestedProfile)) diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index c4826a0ef..d5b3b0b48 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -136,7 +136,6 @@ public: bool isValid() { return mIsValidImage; } - const GBitmap& getImage(); GFXTexHandle getTexture(GFXTextureProfile* requestedProfile); StringTableEntry getImageInfo(); @@ -152,14 +151,14 @@ public: static U32 getAssetById(StringTableEntry assetId, AssetPtr* imageAsset); static U32 getAssetById(String assetId, AssetPtr* imageAsset) { return getAssetById(assetId.c_str(), imageAsset); }; + U32 load(); + protected: virtual void initializeAsset(void); virtual void onAssetRefresh(void); static bool setImageFileName(void* obj, StringTableEntry index, StringTableEntry data) { static_cast(obj)->setImageFileName(data); return false; } static StringTableEntry getImageFileName(void* obj, StringTableEntry data) { return static_cast(obj)->getImageFileName(); } - - void loadImage(); }; DefineConsoleType(TypeImageAssetPtr, ImageAsset) diff --git a/Engine/source/T3D/assets/MaterialAsset.cpp b/Engine/source/T3D/assets/MaterialAsset.cpp index 363d7bc30..02f0a163a 100644 --- a/Engine/source/T3D/assets/MaterialAsset.cpp +++ b/Engine/source/T3D/assets/MaterialAsset.cpp @@ -206,7 +206,7 @@ void MaterialAsset::initializeAsset() } } - loadMaterial(); + load(); } void MaterialAsset::onAssetRefresh() @@ -236,7 +236,7 @@ void MaterialAsset::onAssetRefresh() Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str()); } - loadMaterial(); + load(); } void MaterialAsset::setScriptFile(const char* pScriptFile) @@ -255,7 +255,7 @@ void MaterialAsset::setScriptFile(const char* pScriptFile) //------------------------------------------------------------------------------ -void MaterialAsset::loadMaterial() +U32 MaterialAsset::load() { if (mMaterialDefinition) { @@ -274,7 +274,7 @@ void MaterialAsset::loadMaterial() mLoadedState = Ok; mMaterialDefinition->setInternalName(getAssetId()); mMaterialDefinition->reload(); - return; + return mLoadedState; } } } @@ -286,7 +286,7 @@ void MaterialAsset::loadMaterial() { Con::errorf("MaterialAsset: Unable to find the Material %s", mMatDefinitionName); mLoadedState = BadFileReference; - return; + return mLoadedState; } mMaterialDefinition = matDef; @@ -294,10 +294,11 @@ void MaterialAsset::loadMaterial() mLoadedState = Ok; mMaterialDefinition->setInternalName(getAssetId()); mMaterialDefinition->reload(); - return; + return mLoadedState; } mLoadedState = Failed; + return mLoadedState; } //------------------------------------------------------------------------------ diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index d51f6dabb..4fa868ff7 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -104,7 +104,7 @@ public: static void initPersistFields(); virtual void copyTo(SimObject* object); - void loadMaterial(); + U32 load(); 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 7958212c7..4197b0100 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -308,9 +308,9 @@ void ShapeAsset::_onResourceChanged(const Torque::Path &path) onAssetRefresh(); } -bool ShapeAsset::loadShape() +U32 ShapeAsset::load() { - if (mLoadedState == AssetErrCode::Ok) return true; + if (mLoadedState == AssetErrCode::Ok) return mLoadedState; mMaterialAssets.clear(); mMaterialAssetIds.clear(); @@ -357,7 +357,7 @@ bool ShapeAsset::loadShape() { Con::errorf("ShapeAsset::loadShape : failed to load shape file %s (%s)!", getAssetName(), mFilePath); mLoadedState = BadFileReference; - return false; //if it failed to load, bail out + return mLoadedState; //if it failed to load, bail out } // Construct billboards if not done already if (GFXDevice::devicePresent()) @@ -379,7 +379,7 @@ bool ShapeAsset::loadShape() mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms())) { mLoadedState = MissingAnimatons; - return false; + return mLoadedState; } if (mAnimationAssets[i]->isBlend()) hasBlends = true; @@ -402,7 +402,7 @@ bool ShapeAsset::loadShape() Con::errorf("ShapeAsset::initializeAsset - Unable to acquire reference animation asset %s for asset %s to blend!", mAnimationAssets[i]->getBlendAnimationName(), mAnimationAssets[i]->getAssetName()); { mLoadedState = MissingAnimatons; - return false; + return mLoadedState; } } @@ -412,7 +412,7 @@ bool ShapeAsset::loadShape() Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to set animation clip %s for asset %s to blend!", mAnimationAssets[i]->getAnimationName(), mAnimationAssets[i]->getAssetName()); { mLoadedState = MissingAnimatons; - return false; + return mLoadedState; } } } @@ -422,7 +422,7 @@ bool ShapeAsset::loadShape() mChangeSignal.trigger(); mLoadedState = Ok; - return true; + return mLoadedState; } //------------------------------------------------------------------------------ @@ -706,7 +706,7 @@ DefineEngineMethod(ShapeAsset, generateCachedPreviewImage, const char*, (S32 res "@param resolution Optional field for what resolution to bake the preview image at. Must be pow2\n" "@param overrideMaterialName Optional field for overriding the material used when rendering the shape for the bake.") { - object->loadShape(); + object->load(); return object->generateCachedPreviewImage(resolution, overrideMaterialName); } diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index abeb13c39..29a72e2bf 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -132,11 +132,11 @@ public: /// Declare Console Object. DECLARE_CONOBJECT(ShapeAsset); - bool loadShape(); + U32 load(); TSShape* getShape() { return mShape; } - Resource getShapeResource() { loadShape(); return mShape; } + Resource getShapeResource() { load(); return mShape; } void SplitSequencePathAndName(String& srcPath, String& srcName); StringTableEntry getShapeFileName() { return mFileName; } diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index 3f3a3bf25..d9aeb7f4a 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -322,10 +322,6 @@ void SoundAsset::initializeAsset(void) mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i]; } - - //loadSound(slotCount); - //mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath; - //loadSound(); } void SoundAsset::_onResourceChanged(const Torque::Path &path) @@ -337,9 +333,6 @@ void SoundAsset::_onResourceChanged(const Torque::Path &path) return; } refreshAsset(); - - //loadSound(slotCount); - //loadSound(); } void SoundAsset::onAssetRefresh(void) @@ -354,16 +347,11 @@ void SoundAsset::onAssetRefresh(void) mSoundPath[i] = getOwned() ? expandAssetFilePath(mSoundFile[i]) : mSoundPath[i]; } - - //loadSound(slotCount); - //Update - //mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath; - //loadSound(); } -bool SoundAsset::loadSound() +U32 SoundAsset::load() { - if (mLoadedState == AssetErrCode::Ok) return true; + if (mLoadedState == AssetErrCode::Ok) return mLoadedState; // find out how many active slots we have. U32 numSlots = 0; @@ -394,7 +382,7 @@ bool SoundAsset::loadSound() mSFXProfile[i].setDescription(NULL); mSFXProfile[i].setSoundFileName(StringTable->insert(StringTable->EmptyString())); mSFXProfile[i].setPreload(false); - return false; + return mLoadedState; } else {// = new SFXProfile(mProfileDesc, mSoundFile, mPreload); @@ -427,7 +415,7 @@ bool SoundAsset::loadSound() mSFXProfile[0].setDescription(NULL); mSFXProfile[0].setSoundFileName(StringTable->insert(StringTable->EmptyString())); mSFXProfile[0].setPreload(false); - return false; + return mLoadedState; } else {// = new SFXProfile(mProfileDesc, mSoundFile, mPreload); @@ -446,7 +434,7 @@ bool SoundAsset::loadSound() mChangeSignal.trigger(); mLoadedState = Ok; - return true; + return mLoadedState; } StringTableEntry SoundAsset::getSoundFile(const char* pSoundFile, const U32 slotId) diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index ccd10627b..9aaf51224 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -150,13 +150,13 @@ public: virtual void copyTo(SimObject* object); //SFXResource* getSound() { return mSoundResource; } - Resource getSoundResource(const U32 slotId = 0) { loadSound(); return mSFXProfile[slotId].getResource(); } + Resource getSoundResource(const U32 slotId = 0) { load(); return mSFXProfile[slotId].getResource(); } /// Declare Console Object. DECLARE_CONOBJECT(SoundAsset); void setSoundFile(const char* pSoundFile, const U32 slotId = 0); - bool loadSound(); + U32 load(); StringTableEntry getSoundFile(const char* pSoundFile, const U32 slotId = 0); inline StringTableEntry getSoundPath(const U32 slotId = 0) const { return mSoundPath[slotId]; }; SFXProfile* getSfxProfile(const U32 slotId = 0) { return &mSFXProfile[slotId]; } diff --git a/Engine/source/T3D/assets/TerrainAsset.cpp b/Engine/source/T3D/assets/TerrainAsset.cpp index 4b295a95b..11dd64796 100644 --- a/Engine/source/T3D/assets/TerrainAsset.cpp +++ b/Engine/source/T3D/assets/TerrainAsset.cpp @@ -161,14 +161,14 @@ void TerrainAsset::initializeAsset() mTerrainFilePath = getOwned() ? expandAssetFilePath(mTerrainFileName) : mTerrainFilePath; - loadTerrain(); + load(); } void TerrainAsset::onAssetRefresh() { mTerrainFilePath = getOwned() ? expandAssetFilePath(mTerrainFileName) : mTerrainFilePath; - loadTerrain(); + load(); } void TerrainAsset::setTerrainFileName(const char* pScriptFile) @@ -189,10 +189,10 @@ void TerrainAsset::setTerrainFileName(const char* pScriptFile) refreshAsset(); } -bool TerrainAsset::loadTerrain() +U32 TerrainAsset::load() { if (!Torque::FS::IsFile(mTerrainFilePath)) - return false; + return BadFileReference; mTerrMaterialAssets.clear(); mTerrMaterialAssetIds.clear(); @@ -229,9 +229,9 @@ bool TerrainAsset::loadTerrain() mTerrainFile = ResourceManager::get().load(mTerrainFilePath); if (mTerrainFile) - return true; + return Ok; - return false; + return BadFileReference; } //------------------------------------------------------------------------------ diff --git a/Engine/source/T3D/assets/TerrainAsset.h b/Engine/source/T3D/assets/TerrainAsset.h index 1ae593c62..991bab461 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; }; - bool loadTerrain(); + U32 load(); static bool getAssetByFilename(StringTableEntry fileName, AssetPtr* shapeAsset); static StringTableEntry getAssetIdByFilename(StringTableEntry fileName); diff --git a/Engine/source/T3D/assets/TerrainMaterialAsset.cpp b/Engine/source/T3D/assets/TerrainMaterialAsset.cpp index 18d175f3d..e186e0e4e 100644 --- a/Engine/source/T3D/assets/TerrainMaterialAsset.cpp +++ b/Engine/source/T3D/assets/TerrainMaterialAsset.cpp @@ -202,7 +202,7 @@ void TerrainMaterialAsset::initializeAsset() } } - loadMaterial(); + load(); } void TerrainMaterialAsset::onAssetRefresh() @@ -232,7 +232,7 @@ void TerrainMaterialAsset::onAssetRefresh() Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str()); } - loadMaterial(); + load(); } void TerrainMaterialAsset::setScriptFile(const char* pScriptFile) @@ -251,7 +251,7 @@ void TerrainMaterialAsset::setScriptFile(const char* pScriptFile) //------------------------------------------------------------------------------ -void TerrainMaterialAsset::loadMaterial() +U32 TerrainMaterialAsset::load() { if (mMaterialDefinition) mMaterialDefinition->safeDeleteObject(); @@ -287,7 +287,7 @@ void TerrainMaterialAsset::loadMaterial() } if(mLoadedState == Ok) - return; + return mLoadedState; } else if ((mLoadedState == ScriptLoaded || mLoadedState == DefinitionAlreadyExists) && mMatDefinitionName != StringTable->EmptyString()) { @@ -296,17 +296,18 @@ void TerrainMaterialAsset::loadMaterial() { Con::errorf("TerrainMaterialAsset: Unable to find the Material %s", mMatDefinitionName); mLoadedState = BadFileReference; - return; + return mLoadedState; } mMaterialDefinition = matDef; mLoadedState = Ok; mMaterialDefinition->setInternalName(getAssetId()); - return; + return mLoadedState; } mLoadedState = Failed; + return mLoadedState; } //------------------------------------------------------------------------------ diff --git a/Engine/source/T3D/assets/TerrainMaterialAsset.h b/Engine/source/T3D/assets/TerrainMaterialAsset.h index e8e268255..107c6fc92 100644 --- a/Engine/source/T3D/assets/TerrainMaterialAsset.h +++ b/Engine/source/T3D/assets/TerrainMaterialAsset.h @@ -89,7 +89,7 @@ public: static void initPersistFields(); virtual void copyTo(SimObject* object); - void loadMaterial(); + U32 load(); StringTableEntry getMaterialDefinitionName() { return mMatDefinitionName; } SimObjectPtr getMaterialDefinition() { return mMaterialDefinition; } diff --git a/Engine/source/assets/assetBase.h b/Engine/source/assets/assetBase.h index bffc8d7ba..ad6d4e95b 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; }; AssetBase(); virtual ~AssetBase();