Move fast-forward of particle systems outside of OgreNifLoader (Fixes #1830)

Particle systems were being fast-forwarded before the skeleton base was attached, so particles without the LocalSpace flag would spawn at an incorrect position.
deque
scrawl 11 years ago
parent 03cb66c342
commit 83037a1a91

@ -110,6 +110,11 @@ void Animation::setObjectRoot(const std::string &model, bool baseonly)
mObjectRoot = (!baseonly ? NifOgre::Loader::createObjects(mInsert, mdlname) :
NifOgre::Loader::createObjectBase(mInsert, mdlname));
// Fast forward auto-play particles, which will have been set up as Emitting by the loader.
for (unsigned int i=0; i<mObjectRoot->mParticles.size(); ++i)
mObjectRoot->mParticles[i]->fastForward(1, 0.1);
if(mObjectRoot->mSkelBase)
{
mSkelBase = mObjectRoot->mSkelBase;

@ -552,6 +552,10 @@ NifOgre::ObjectScenePtr NpcAnimation::insertBoundedPart(const std::string &model
std::for_each(objects->mEntities.begin(), objects->mEntities.end(), SetObjectGroup(group));
std::for_each(objects->mParticles.begin(), objects->mParticles.end(), SetObjectGroup(group));
// Fast forward auto-play particles, which will have been set up as Emitting by the loader.
for (unsigned int i=0; i<objects->mParticles.size(); ++i)
objects->mParticles[i]->fastForward(1, 0.1);
if(objects->mSkelBase)
{
Ogre::AnimationStateSet *aset = objects->mSkelBase->getAllAnimationStates();

@ -916,8 +916,10 @@ class NIFObjectLoader
scene->mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
if (partflags&Nif::NiNode::ParticleFlag_AutoPlay)
partsys->fastForward(1, 0.1);
// Emitting state will be overwritten on frame update by the ParticleSystemController,
// but set up an initial value anyway so the user can fast-forward particle systems
// immediately after creation if desired.
partsys->setEmitting(partflags&Nif::NiNode::ParticleFlag_AutoPlay);
}
ctrl = ctrl->next;
}

Loading…
Cancel
Save