mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 16:14:01 +02:00
give particle trails a nice smooth path between frames
This commit is contained in:
parent
9066fb0622
commit
58539171a3
2 changed files with 8 additions and 5 deletions
|
@ -103,6 +103,7 @@ EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID
|
|||
// our non-pure virtual subclass for now...
|
||||
ParticleEffectEntityItem::ParticleEffectEntityItem(const EntityItemID& entityItemID) :
|
||||
EntityItem(entityItemID),
|
||||
_previousPosition(getPosition()),
|
||||
_lastSimulated(usecTimestampNow())
|
||||
{
|
||||
_type = EntityTypes::ParticleEffect;
|
||||
|
@ -623,7 +624,8 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
|||
}
|
||||
|
||||
// emit a new particle at tail index.
|
||||
_particles.push_back(createParticle());
|
||||
_particles.push_back(createParticle(glm::mix(_previousPosition, getPosition(),
|
||||
(deltaTime - timeLeftInFrame) / deltaTime)));
|
||||
auto particle = _particles.back();
|
||||
particle.lifetime += timeLeftInFrame;
|
||||
|
||||
|
@ -637,15 +639,16 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
|||
|
||||
_timeUntilNextEmit -= timeLeftInFrame;
|
||||
}
|
||||
_previousPosition = getPosition();
|
||||
}
|
||||
|
||||
ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
|
||||
ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle(const glm::vec3& position) {
|
||||
Particle particle;
|
||||
|
||||
|
||||
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
||||
if (getEmitterShouldTrail()) {
|
||||
particle.position = getPosition();
|
||||
particle.position = position;
|
||||
}
|
||||
// Position, velocity, and acceleration
|
||||
if (_polarStart == 0.0f && _polarFinish == 0.0f && _emitDimensions.z == 0.0f) {
|
||||
|
|
|
@ -227,7 +227,7 @@ protected:
|
|||
|
||||
bool isAnimatingSomething() const;
|
||||
|
||||
Particle createParticle();
|
||||
Particle createParticle(const glm::vec3& position);
|
||||
void stepSimulation(float deltaTime);
|
||||
void integrateParticle(Particle& particle, float deltaTime);
|
||||
|
||||
|
@ -275,7 +275,7 @@ protected:
|
|||
float _azimuthStart = DEFAULT_AZIMUTH_START;
|
||||
float _azimuthFinish = DEFAULT_AZIMUTH_FINISH;
|
||||
|
||||
|
||||
glm::vec3 _previousPosition;
|
||||
quint64 _lastSimulated { 0 };
|
||||
bool _isEmitting { true };
|
||||
|
||||
|
|
Loading…
Reference in a new issue