diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index ab237696f..d0b652851 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -211,7 +211,7 @@ void ShapeAsset::setShapeConstructorFile(const char* pShapeConstructorFile) void ShapeAsset::_onResourceChanged(const Torque::Path &path) { - if (path != Torque::Path(mFileName) ) + if (path != Torque::Path(mFilePath) ) return; refreshAsset(); @@ -313,7 +313,7 @@ bool ShapeAsset::loadShape() } } - onShapeChanged.trigger(this); + mChangeSignal.trigger(); return true; } diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index a78dcddbb..65e0a4ca9 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -76,6 +76,10 @@ protected: Vector mAnimationAssetIds; Vector> mAnimationAssets; + typedef Signal ShapeAssetChanged; + + ShapeAssetChanged mChangeSignal; + public: ShapeAsset(); virtual ~ShapeAsset(); @@ -122,7 +126,7 @@ public: void _onResourceChanged(const Torque::Path &path); - Signal< void(ShapeAsset*) > onShapeChanged; + ShapeAssetChanged& getChangedSignal() { return mChangeSignal; } void setShapeFile(const char* pScriptFile); inline StringTableEntry getShapeFile(void) const { return mFileName; }; diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 4d3fbed59..93693a2dc 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -402,7 +402,7 @@ bool TSStatic::onAdd() setRenderTransform(mObjToWorld); // Register for the resource change signal. - ResourceManager::get().getChangedSignal().notify(this, &TSStatic::_onResourceChanged); + //ResourceManager::get().getChangedSignal().notify(this, &TSStatic::_onResourceChanged); addToScene(); @@ -427,6 +427,11 @@ bool TSStatic::onAdd() bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId) { + if (!mShapeAsset.isNull()) + { + mShapeAsset->getChangedSignal().remove(this, &TSStatic::_onAssetChanged); + } + 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 @@ -434,6 +439,8 @@ bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId) if (mShapeAsset.getAssetId() != StringTable->insert("Core_Rendering:noshape")) { mShapeName = StringTable->EmptyString(); + + mShapeAsset->getChangedSignal().notify(this, &TSStatic::_onAssetChanged); } _createShape(); @@ -658,7 +665,7 @@ void TSStatic::onRemove() removeFromScene(); // Remove the resource change signal. - ResourceManager::get().getChangedSignal().remove(this, &TSStatic::_onResourceChanged); + //ResourceManager::get().getChangedSignal().remove(this, &TSStatic::_onResourceChanged); delete mShapeInstance; mShapeInstance = NULL; @@ -667,6 +674,9 @@ void TSStatic::onRemove() if (isClientObject()) mCubeReflector.unregisterReflector(); + if(!mShapeAsset.isNull()) + mShapeAsset->getChangedSignal().remove(this, &TSStatic::_onAssetChanged); + Parent::onRemove(); } @@ -679,6 +689,12 @@ void TSStatic::_onResourceChanged(const Torque::Path& path) _updateShouldTick(); } +void TSStatic::_onAssetChanged() +{ + _createShape(); + _updateShouldTick(); +} + void TSStatic::setSkinName(const char* name) { if (!isGhost()) @@ -917,9 +933,10 @@ void TSStatic::prepRenderImage(SceneRenderState* state) state->getRenderPass()->addInst(ri); } - mShapeInstance->animate(); if (mShapeInstance) { + mShapeInstance->animate(); + if (mUseAlphaFade || smUseStaticObjectFade) { mShapeInstance->setAlphaAlways(mAlphaFade); diff --git a/Engine/source/T3D/tsStatic.h b/Engine/source/T3D/tsStatic.h index c08986b9c..57316a9d9 100644 --- a/Engine/source/T3D/tsStatic.h +++ b/Engine/source/T3D/tsStatic.h @@ -172,6 +172,7 @@ protected: void _renderNormals(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat); void _onResourceChanged(const Torque::Path& path); + void _onAssetChanged(); // ProcessObject virtual void processTick(const Move* move);