|
|
|
@ -187,14 +187,12 @@ namespace
|
|
|
|
|
RemoveFinishedCallbackVisitor()
|
|
|
|
|
: RemoveVisitor()
|
|
|
|
|
, mHasMagicEffects(false)
|
|
|
|
|
, mEffectId(-1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoveFinishedCallbackVisitor(int effectId)
|
|
|
|
|
: RemoveVisitor()
|
|
|
|
|
, mHasMagicEffects(false)
|
|
|
|
|
, mEffectId(effectId)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -214,9 +212,63 @@ namespace
|
|
|
|
|
MWRender::UpdateVfxCallback* vfxCallback = dynamic_cast<MWRender::UpdateVfxCallback*>(callback);
|
|
|
|
|
if (vfxCallback)
|
|
|
|
|
{
|
|
|
|
|
bool finished = vfxCallback->mFinished;
|
|
|
|
|
bool toRemove = mEffectId >= 0 && vfxCallback->mParams.mEffectId == mEffectId;
|
|
|
|
|
if (finished || toRemove)
|
|
|
|
|
if (vfxCallback->mFinished)
|
|
|
|
|
mToRemove.push_back(std::make_pair(group.asNode(), group.getParent(0)));
|
|
|
|
|
else
|
|
|
|
|
mHasMagicEffects = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void apply(osg::MatrixTransform &node)
|
|
|
|
|
{
|
|
|
|
|
traverse(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void apply(osg::Geometry&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int mEffectId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RemoveCallbackVisitor : public RemoveVisitor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool mHasMagicEffects;
|
|
|
|
|
|
|
|
|
|
RemoveCallbackVisitor()
|
|
|
|
|
: RemoveVisitor()
|
|
|
|
|
, mHasMagicEffects(false)
|
|
|
|
|
, mEffectId(-1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RemoveCallbackVisitor(int effectId)
|
|
|
|
|
: RemoveVisitor()
|
|
|
|
|
, mHasMagicEffects(false)
|
|
|
|
|
, mEffectId(effectId)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void apply(osg::Node &node)
|
|
|
|
|
{
|
|
|
|
|
traverse(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void apply(osg::Group &group)
|
|
|
|
|
{
|
|
|
|
|
traverse(group);
|
|
|
|
|
|
|
|
|
|
osg::Callback* callback = group.getUpdateCallback();
|
|
|
|
|
if (callback)
|
|
|
|
|
{
|
|
|
|
|
MWRender::UpdateVfxCallback* vfxCallback = dynamic_cast<MWRender::UpdateVfxCallback*>(callback);
|
|
|
|
|
if (vfxCallback)
|
|
|
|
|
{
|
|
|
|
|
bool toRemove = mEffectId < 0 || vfxCallback->mParams.mEffectId == mEffectId;
|
|
|
|
|
if (toRemove)
|
|
|
|
|
mToRemove.push_back(std::make_pair(group.asNode(), group.getParent(0)));
|
|
|
|
|
else
|
|
|
|
|
mHasMagicEffects = true;
|
|
|
|
@ -546,8 +598,8 @@ namespace MWRender
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Remove effect immediately
|
|
|
|
|
mParams.mObjects.reset();
|
|
|
|
|
// Hide effect immediately
|
|
|
|
|
node->setNodeMask(0);
|
|
|
|
|
mFinished = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1608,7 +1660,6 @@ namespace MWRender
|
|
|
|
|
params.mLoop = loop;
|
|
|
|
|
params.mEffectId = effectId;
|
|
|
|
|
params.mBoneName = bonename;
|
|
|
|
|
params.mObjects = PartHolderPtr(new PartHolder(node));
|
|
|
|
|
params.mAnimTime = std::shared_ptr<EffectAnimationTime>(new EffectAnimationTime);
|
|
|
|
|
trans->addUpdateCallback(new UpdateVfxCallback(params));
|
|
|
|
|
|
|
|
|
@ -1623,12 +1674,17 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
void Animation::removeEffect(int effectId)
|
|
|
|
|
{
|
|
|
|
|
RemoveFinishedCallbackVisitor visitor(effectId);
|
|
|
|
|
RemoveCallbackVisitor visitor(effectId);
|
|
|
|
|
mInsert->accept(visitor);
|
|
|
|
|
visitor.remove();
|
|
|
|
|
mHasMagicEffects = visitor.mHasMagicEffects;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::removeEffects()
|
|
|
|
|
{
|
|
|
|
|
removeEffect(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::getLoopingEffects(std::vector<int> &out) const
|
|
|
|
|
{
|
|
|
|
|
if (!mHasMagicEffects)
|
|
|
|
@ -1892,12 +1948,12 @@ namespace MWRender
|
|
|
|
|
PartHolder::~PartHolder()
|
|
|
|
|
{
|
|
|
|
|
if (mNode.get() && !mNode->getNumParents())
|
|
|
|
|
Log(Debug::Verbose) << "Part has no parents" ;
|
|
|
|
|
Log(Debug::Verbose) << "Part \"" << mNode->getName() << "\" has no parents" ;
|
|
|
|
|
|
|
|
|
|
if (mNode.get() && mNode->getNumParents())
|
|
|
|
|
{
|
|
|
|
|
if (mNode->getNumParents() > 1)
|
|
|
|
|
Log(Debug::Verbose) << "Part has multiple (" << mNode->getNumParents() << ") parents";
|
|
|
|
|
Log(Debug::Verbose) << "Part \"" << mNode->getName() << "\" has multiple (" << mNode->getNumParents() << ") parents";
|
|
|
|
|
mNode->getParent(0)->removeChild(mNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|