mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Clean up particle vertex handling
This commit is contained in:
parent
1c83e4936d
commit
5310dd6807
@ -37,7 +37,7 @@ public:
|
|||||||
float lifetime;
|
float lifetime;
|
||||||
float lifespan;
|
float lifespan;
|
||||||
float timestamp;
|
float timestamp;
|
||||||
int vertex;
|
unsigned short vertex;
|
||||||
};
|
};
|
||||||
|
|
||||||
float velocity;
|
float velocity;
|
||||||
|
@ -963,6 +963,9 @@ namespace NifOsg
|
|||||||
if (particle.lifespan <= 0)
|
if (particle.lifespan <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (particle.vertex >= particledata->vertices.size())
|
||||||
|
continue;
|
||||||
|
|
||||||
ParticleAgeSetter particletemplate(std::max(0.f, particle.lifetime));
|
ParticleAgeSetter particletemplate(std::max(0.f, particle.lifetime));
|
||||||
|
|
||||||
osgParticle::Particle* created = partsys->createParticle(&particletemplate);
|
osgParticle::Particle* created = partsys->createParticle(&particletemplate);
|
||||||
@ -971,16 +974,16 @@ namespace NifOsg
|
|||||||
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
||||||
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
||||||
created->setVelocity(particle.velocity);
|
created->setVelocity(particle.velocity);
|
||||||
const osg::Vec3f& position = particledata->vertices.at(particle.vertex);
|
const osg::Vec3f& position = particledata->vertices[particle.vertex];
|
||||||
created->setPosition(position);
|
created->setPosition(position);
|
||||||
|
|
||||||
osg::Vec4f partcolor (1.f,1.f,1.f,1.f);
|
osg::Vec4f partcolor (1.f,1.f,1.f,1.f);
|
||||||
if (particle.vertex < int(particledata->colors.size()))
|
if (particle.vertex < particledata->colors.size())
|
||||||
partcolor = particledata->colors.at(particle.vertex);
|
partcolor = particledata->colors[particle.vertex];
|
||||||
|
|
||||||
float size = partctrl->size;
|
float size = partctrl->size;
|
||||||
if (particle.vertex < int(particledata->sizes.size()))
|
if (particle.vertex < particledata->sizes.size())
|
||||||
size *= particledata->sizes.at(particle.vertex);
|
size *= particledata->sizes[particle.vertex];
|
||||||
|
|
||||||
created->setSizeRange(osgParticle::rangef(size, size));
|
created->setSizeRange(osgParticle::rangef(size, size));
|
||||||
box.expandBy(osg::BoundingSphere(position, size));
|
box.expandBy(osg::BoundingSphere(position, size));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user