add 'min_angular_vel', 'max_angular_vel' properties
This commit is contained in:
@@ -88,6 +88,11 @@ void Emitter::update(
|
||||
particle.angle =
|
||||
random.randFloat() * preset.angleSpread * glm::pi<float>() * 2;
|
||||
}
|
||||
particle.angularVelocity =
|
||||
(preset.minAngularVelocity +
|
||||
random.randFloat() *
|
||||
(preset.maxAngularVelocity - preset.minAngularVelocity)) *
|
||||
((random.rand() % 2) * 2 - 1);
|
||||
|
||||
glm::vec3 spawnOffset = generate_coord(preset.spawnShape);
|
||||
spawnOffset *= preset.spawnSpread;
|
||||
|
||||
@@ -29,6 +29,8 @@ struct Particle {
|
||||
UVRegion region;
|
||||
/// @brief Current rotation angle
|
||||
float angle;
|
||||
/// @brief Angular velocity
|
||||
float angularVelocity;
|
||||
};
|
||||
|
||||
class Texture;
|
||||
|
||||
@@ -31,12 +31,14 @@ static inline void update_particle(
|
||||
const auto& preset = particle.emitter->preset;
|
||||
auto& pos = particle.position;
|
||||
auto& vel = particle.velocity;
|
||||
auto& angle = particle.angle;
|
||||
|
||||
vel += delta * preset.acceleration;
|
||||
if (preset.collision && chunks.isObstacleAt(pos + vel * delta)) {
|
||||
vel *= 0.0f;
|
||||
}
|
||||
pos += vel * delta;
|
||||
angle += particle.angularVelocity * delta;
|
||||
particle.lifetime -= delta;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user