variation on #387 that also introduces errorcodes

This commit is contained in:
AzaezelX 2020-12-01 19:16:36 -06:00
parent 80eb4ab2ba
commit 220771d2fe
4 changed files with 123 additions and 23 deletions

View file

@ -119,6 +119,7 @@ ShapeAsset::ShapeAsset()
mConstructorFileName = StringTable->EmptyString();
mFilePath = StringTable->EmptyString();
mConstructorFilePath = StringTable->EmptyString();
mLoadedState = AssetErrCode::NotLoaded;
}
//-----------------------------------------------------------------------------
@ -264,7 +265,8 @@ bool ShapeAsset::loadShape()
if (!mShape)
{
Con::errorf("StaticMesh::updateShape : failed to load shape file!");
Con::errorf("ShapeAsset::loadShape : failed to load shape file!");
mLoadedState = BadFileReference;
return false; //if it failed to load, bail out
}
@ -280,8 +282,10 @@ bool ShapeAsset::loadShape()
if (!mShape->addSequence(srcPath, srcName, srcName,
mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms()))
{
mLoadedState = MissingAnimatons;
return false;
}
if (mAnimationAssets[i]->isBlend())
hasBlends = true;
}
@ -300,14 +304,20 @@ bool ShapeAsset::loadShape()
if (blendAnimAsset.isNull())
{
Con::errorf("ShapeAsset::initializeAsset - Unable to acquire reference animation asset %s for asset %s to blend!", mAnimationAssets[i]->getBlendAnimationName(), mAnimationAssets[i]->getAssetName());
return false;
{
mLoadedState = MissingAnimatons;
return false;
}
}
String refAnimName = blendAnimAsset->getAnimationName();
if (!mShape->setSequenceBlend(mAnimationAssets[i]->getAnimationName(), true, blendAnimAsset->getAnimationName(), mAnimationAssets[i]->getBlendFrame()))
{
Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to set animation clip %s for asset %s to blend!", mAnimationAssets[i]->getAnimationName(), mAnimationAssets[i]->getAssetName());
return false;
{
mLoadedState = MissingAnimatons;
return false;
}
}
}
}
@ -315,6 +325,7 @@ bool ShapeAsset::loadShape()
mChangeSignal.trigger();
mLoadedState = Ok;
return true;
}
@ -410,21 +421,21 @@ StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName)
return shapeAssetId;
}
bool ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset)
U32 ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset)
{
(*shapeAsset) = assetId;
if (!shapeAsset->isNull())
return true;
if ((*shapeAsset))
return (*shapeAsset)->mLoadedState;
//Didn't work, so have us fall back to a placeholder asset
StringTableEntry noShapeId = StringTable->insert("Core_Rendering:noshape");
shapeAsset->setAssetId(noShapeId);
(*shapeAsset)->mLoadedState = AssetErrCode::UsingFallback;
if (shapeAsset->notNull())
return AssetErrCode::UsingFallback;
if (!shapeAsset->isNull())
return true;
return false;
return AssetErrCode::Failed;
}
//------------------------------------------------------------------------------
@ -503,6 +514,7 @@ DefineEngineMethod(ShapeAsset, getAnimation, ShapeAnimationAsset*, (S32 index),
// GuiInspectorTypeAssetId
//-----------------------------------------------------------------------------
#ifdef TORQUE_TOOLS
IMPLEMENT_CONOBJECT(GuiInspectorTypeShapeAssetPtr);
ConsoleDocClass(GuiInspectorTypeShapeAssetPtr,
@ -596,6 +608,8 @@ void GuiInspectorTypeShapeAssetId::consoleInit()
ConsoleBaseType::getType(TypeShapeAssetId)->setInspectorFieldType("GuiInspectorTypeShapeAssetId");
}
#endif
DefineEngineMethod(ShapeAsset, getShapeFile, const char*, (), ,
"Creates a new script asset using the targetFilePath.\n"
"@return The bool result of calling exec")