Changed methods slightly to ensure non-magic projectiles do not receive lights

This commit is contained in:
mrohrlach 2016-12-03 15:42:24 -07:00
parent 83945cf280
commit 49ce80346c
2 changed files with 26 additions and 22 deletions

View file

@ -138,7 +138,7 @@ namespace MWWorld
}; };
void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, std::string texture) void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, bool isMagic, std::string texture)
{ {
state.mNode = new osg::PositionAttitudeTransform; state.mNode = new osg::PositionAttitudeTransform;
state.mNode->setNodeMask(MWRender::Mask_Effect); state.mNode->setNodeMask(MWRender::Mask_Effect);
@ -169,7 +169,9 @@ namespace MWWorld
mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, findVisitor.mFoundNode); mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, findVisitor.mFoundNode);
} }
// Add projectile light if (isMagic)
{
// Add magic bolt light
osg::ref_ptr<osg::Light> projectileLight(new osg::Light); osg::ref_ptr<osg::Light> projectileLight(new osg::Light);
projectileLight->setDiffuse(osg::Vec4(0.95f, 0.71f, 0.25f, 1.0f)); projectileLight->setDiffuse(osg::Vec4(0.95f, 0.71f, 0.25f, 1.0f));
projectileLight->setAmbient(osg::Vec4(0.32f, 0.08f, 0.01f, 1.0f)); projectileLight->setAmbient(osg::Vec4(0.32f, 0.08f, 0.01f, 1.0f));
@ -177,13 +179,15 @@ namespace MWWorld
projectileLight->setLinearAttenuation(0.5f / 15); projectileLight->setLinearAttenuation(0.5f / 15);
projectileLight->setPosition(osg::Vec4(pos, 1.0)); projectileLight->setPosition(osg::Vec4(pos, 1.0));
// Add projectile light source // Add magic bolt light source
SceneUtil::LightSource* projectileLightSource = new SceneUtil::LightSource; SceneUtil::LightSource* projectileLightSource = new SceneUtil::LightSource;
projectileLightSource->setNodeMask(MWRender::Mask_Lighting); projectileLightSource->setNodeMask(MWRender::Mask_Lighting);
projectileLightSource->setRadius(66.f); projectileLightSource->setRadius(66.f);
// Attach to scene node
state.mNode->addChild(projectileLightSource); state.mNode->addChild(projectileLightSource);
projectileLightSource->setLight(projectileLight); projectileLightSource->setLight(projectileLight);
}
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor; SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
@ -248,7 +252,7 @@ namespace MWWorld
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0)); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0));
MWWorld::Ptr ptr = ref.getPtr(); MWWorld::Ptr ptr = ref.getPtr();
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true, texture); createModel(state, ptr.getClass().getModel(ptr), pos, orient, true, true, texture);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
for (size_t it = 0; it != state.mSoundIds.size(); it++) for (size_t it = 0; it != state.mSoundIds.size(); it++)
@ -272,7 +276,7 @@ namespace MWWorld
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId()); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId());
MWWorld::Ptr ptr = ref.getPtr(); MWWorld::Ptr ptr = ref.getPtr();
createModel(state, ptr.getClass().getModel(ptr), pos, orient, false); createModel(state, ptr.getClass().getModel(ptr), pos, orient, false, false);
mProjectiles.push_back(state); mProjectiles.push_back(state);
} }
@ -502,7 +506,7 @@ namespace MWWorld
return true; return true;
} }
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), false); createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), false, false);
mProjectiles.push_back(state); mProjectiles.push_back(state);
return true; return true;
@ -537,7 +541,7 @@ namespace MWWorld
return true; return true;
} }
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), true, texture); createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), true, true, texture);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();

View file

@ -122,7 +122,7 @@ namespace MWWorld
void moveProjectiles(float dt); void moveProjectiles(float dt);
void moveMagicBolts(float dt); void moveMagicBolts(float dt);
void createModel (State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, std::string texture = ""); void createModel (State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, bool isMagic, std::string texture = "");
void update (State& state, float duration); void update (State& state, float duration);
void operator=(const ProjectileManager&); void operator=(const ProjectileManager&);