enable particle shading and force particle normal to (0.3,0.3,0.3)

and update changelog
pull/2781/head
Julien Valentin 4 years ago
parent 6e2a651252
commit 886fd5efc9

@ -1,6 +1,8 @@
0.47.0
------
Bug #3676: NiParticleColorModifier isn't applied properly
Bug #4949: Incorrect particle lighting when force shaders = true
Bug #5358: ForceGreeting always resets the dialogue window completely
Bug #5363: Enchantment autocalc not always 0/1
Bug #5364: Script fails/stops if trying to startscript an unknown script

@ -1078,6 +1078,8 @@ namespace NifOsg
trans->addChild(toAttach);
parentNode->addChild(trans);
}
// create partsys stateset in order to pass in ShaderVisitor like all other Drawables
partsys->getOrCreateStateSet();
}
void triCommonToGeometry(osg::Geometry *geometry, const std::vector<osg::Vec3f>& vertices, const std::vector<osg::Vec3f>& normals, const std::vector<std::vector<osg::Vec2f>>& uvlist, const std::vector<osg::Vec4f>& colors, const std::vector<unsigned int>& boundTextures, const std::string& name)

@ -2,6 +2,7 @@
#include <limits>
#include <osg/Version>
#include <osg/MatrixTransform>
#include <osg/Geometry>
@ -19,12 +20,19 @@ ParticleSystem::ParticleSystem()
: osgParticle::ParticleSystem()
, mQuota(std::numeric_limits<int>::max())
{
mNormalArray = new osg::Vec3Array(1);
mNormalArray->setBinding(osg::Array::BIND_OVERALL);
(*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3);
}
ParticleSystem::ParticleSystem(const ParticleSystem &copy, const osg::CopyOp &copyop)
: osgParticle::ParticleSystem(copy, copyop)
, mQuota(copy.mQuota)
{
mNormalArray = new osg::Vec3Array(1);
mNormalArray->setBinding(osg::Array::BIND_OVERALL);
(*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3);
// For some reason the osgParticle constructor doesn't copy the particles
for (int i=0;i<copy.numParticles()-copy.numDeadParticles();++i)
ParticleSystem::createParticle(copy.getParticle(i));
@ -42,6 +50,25 @@ osgParticle::Particle* ParticleSystem::createParticle(const osgParticle::Particl
return nullptr;
}
void ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo) const
{
osg::State & state = *renderInfo.getState();
#if OSG_MIN_VERSION_REQUIRED(3, 5, 6)
if(state.useVertexArrayObject(getUseVertexArrayObject()))
{
state.getCurrentVertexArrayState()->assignNormalArrayDispatcher();
state.getCurrentVertexArrayState()->setNormalArray(state, mNormalArray);
}
else
{
state.getAttributeDispatchers().activateNormalArray(mNormalArray);
}
#else
state.Normal(0.3, 0.3, 0.3);
#endif
osgParticle::ParticleSystem::drawImplementation(renderInfo);
}
void InverseWorldMatrix::operator()(osg::Node *node, osg::NodeVisitor *nv)
{
if (nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)

@ -36,8 +36,11 @@ namespace NifOsg
void setQuota(int quota);
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
private:
int mQuota;
osg::ref_ptr<osg::Vec3Array> mNormalArray;
};
// HACK: Particle doesn't allow setting the initial age, but we need this for loading the particle system state

Loading…
Cancel
Save