mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Fixes the hook-ins so when a shape asset is changed, tsstatics now are correctly triggered for a reload
This commit is contained in:
parent
1600bfaf57
commit
8fbad31b43
4 changed files with 28 additions and 6 deletions
|
|
@ -211,7 +211,7 @@ void ShapeAsset::setShapeConstructorFile(const char* pShapeConstructorFile)
|
||||||
|
|
||||||
void ShapeAsset::_onResourceChanged(const Torque::Path &path)
|
void ShapeAsset::_onResourceChanged(const Torque::Path &path)
|
||||||
{
|
{
|
||||||
if (path != Torque::Path(mFileName) )
|
if (path != Torque::Path(mFilePath) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
refreshAsset();
|
refreshAsset();
|
||||||
|
|
@ -313,7 +313,7 @@ bool ShapeAsset::loadShape()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onShapeChanged.trigger(this);
|
mChangeSignal.trigger();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,10 @@ protected:
|
||||||
Vector<StringTableEntry> mAnimationAssetIds;
|
Vector<StringTableEntry> mAnimationAssetIds;
|
||||||
Vector<AssetPtr<ShapeAnimationAsset>> mAnimationAssets;
|
Vector<AssetPtr<ShapeAnimationAsset>> mAnimationAssets;
|
||||||
|
|
||||||
|
typedef Signal<void()> ShapeAssetChanged;
|
||||||
|
|
||||||
|
ShapeAssetChanged mChangeSignal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShapeAsset();
|
ShapeAsset();
|
||||||
virtual ~ShapeAsset();
|
virtual ~ShapeAsset();
|
||||||
|
|
@ -122,7 +126,7 @@ public:
|
||||||
|
|
||||||
void _onResourceChanged(const Torque::Path &path);
|
void _onResourceChanged(const Torque::Path &path);
|
||||||
|
|
||||||
Signal< void(ShapeAsset*) > onShapeChanged;
|
ShapeAssetChanged& getChangedSignal() { return mChangeSignal; }
|
||||||
|
|
||||||
void setShapeFile(const char* pScriptFile);
|
void setShapeFile(const char* pScriptFile);
|
||||||
inline StringTableEntry getShapeFile(void) const { return mFileName; };
|
inline StringTableEntry getShapeFile(void) const { return mFileName; };
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ bool TSStatic::onAdd()
|
||||||
setRenderTransform(mObjToWorld);
|
setRenderTransform(mObjToWorld);
|
||||||
|
|
||||||
// Register for the resource change signal.
|
// Register for the resource change signal.
|
||||||
ResourceManager::get().getChangedSignal().notify(this, &TSStatic::_onResourceChanged);
|
//ResourceManager::get().getChangedSignal().notify(this, &TSStatic::_onResourceChanged);
|
||||||
|
|
||||||
addToScene();
|
addToScene();
|
||||||
|
|
||||||
|
|
@ -427,6 +427,11 @@ bool TSStatic::onAdd()
|
||||||
|
|
||||||
bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId)
|
bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId)
|
||||||
{
|
{
|
||||||
|
if (!mShapeAsset.isNull())
|
||||||
|
{
|
||||||
|
mShapeAsset->getChangedSignal().remove(this, &TSStatic::_onAssetChanged);
|
||||||
|
}
|
||||||
|
|
||||||
if (ShapeAsset::getAssetById(shapeAssetId, &mShapeAsset))
|
if (ShapeAsset::getAssetById(shapeAssetId, &mShapeAsset))
|
||||||
{
|
{
|
||||||
//Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break
|
//Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break
|
||||||
|
|
@ -434,6 +439,8 @@ bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId)
|
||||||
if (mShapeAsset.getAssetId() != StringTable->insert("Core_Rendering:noshape"))
|
if (mShapeAsset.getAssetId() != StringTable->insert("Core_Rendering:noshape"))
|
||||||
{
|
{
|
||||||
mShapeName = StringTable->EmptyString();
|
mShapeName = StringTable->EmptyString();
|
||||||
|
|
||||||
|
mShapeAsset->getChangedSignal().notify(this, &TSStatic::_onAssetChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
_createShape();
|
_createShape();
|
||||||
|
|
@ -658,7 +665,7 @@ void TSStatic::onRemove()
|
||||||
removeFromScene();
|
removeFromScene();
|
||||||
|
|
||||||
// Remove the resource change signal.
|
// Remove the resource change signal.
|
||||||
ResourceManager::get().getChangedSignal().remove(this, &TSStatic::_onResourceChanged);
|
//ResourceManager::get().getChangedSignal().remove(this, &TSStatic::_onResourceChanged);
|
||||||
|
|
||||||
delete mShapeInstance;
|
delete mShapeInstance;
|
||||||
mShapeInstance = NULL;
|
mShapeInstance = NULL;
|
||||||
|
|
@ -667,6 +674,9 @@ void TSStatic::onRemove()
|
||||||
if (isClientObject())
|
if (isClientObject())
|
||||||
mCubeReflector.unregisterReflector();
|
mCubeReflector.unregisterReflector();
|
||||||
|
|
||||||
|
if(!mShapeAsset.isNull())
|
||||||
|
mShapeAsset->getChangedSignal().remove(this, &TSStatic::_onAssetChanged);
|
||||||
|
|
||||||
Parent::onRemove();
|
Parent::onRemove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -679,6 +689,12 @@ void TSStatic::_onResourceChanged(const Torque::Path& path)
|
||||||
_updateShouldTick();
|
_updateShouldTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSStatic::_onAssetChanged()
|
||||||
|
{
|
||||||
|
_createShape();
|
||||||
|
_updateShouldTick();
|
||||||
|
}
|
||||||
|
|
||||||
void TSStatic::setSkinName(const char* name)
|
void TSStatic::setSkinName(const char* name)
|
||||||
{
|
{
|
||||||
if (!isGhost())
|
if (!isGhost())
|
||||||
|
|
@ -917,9 +933,10 @@ void TSStatic::prepRenderImage(SceneRenderState* state)
|
||||||
state->getRenderPass()->addInst(ri);
|
state->getRenderPass()->addInst(ri);
|
||||||
}
|
}
|
||||||
|
|
||||||
mShapeInstance->animate();
|
|
||||||
if (mShapeInstance)
|
if (mShapeInstance)
|
||||||
{
|
{
|
||||||
|
mShapeInstance->animate();
|
||||||
|
|
||||||
if (mUseAlphaFade || smUseStaticObjectFade)
|
if (mUseAlphaFade || smUseStaticObjectFade)
|
||||||
{
|
{
|
||||||
mShapeInstance->setAlphaAlways(mAlphaFade);
|
mShapeInstance->setAlphaAlways(mAlphaFade);
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ protected:
|
||||||
void _renderNormals(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat);
|
void _renderNormals(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat);
|
||||||
|
|
||||||
void _onResourceChanged(const Torque::Path& path);
|
void _onResourceChanged(const Torque::Path& path);
|
||||||
|
void _onAssetChanged();
|
||||||
|
|
||||||
// ProcessObject
|
// ProcessObject
|
||||||
virtual void processTick(const Move* move);
|
virtual void processTick(const Move* move);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue