mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed particles.
This commit is contained in:
parent
cb59c8017e
commit
df70976ff5
@ -1,11 +1,11 @@
|
|||||||
BasicBeam(
|
BasicBeam(
|
||||||
buildup_duration: 0.25,
|
buildup_duration: 0.25,
|
||||||
recover_duration: 0.25,
|
recover_duration: 0.25,
|
||||||
beam_duration: 0.5,
|
beam_duration: 1.0,
|
||||||
base_hps: 0,
|
base_hps: 0,
|
||||||
base_dps: 150,
|
base_dps: 150,
|
||||||
tick_rate: 3.0,
|
tick_rate: 3.0,
|
||||||
range: 15.0,
|
range: 20.0,
|
||||||
max_angle: 10.0,
|
max_angle: 10.0,
|
||||||
lifesteal_eff: 0.0,
|
lifesteal_eff: 0.0,
|
||||||
energy_regen: 0,
|
energy_regen: 0,
|
||||||
|
@ -57,6 +57,7 @@ const int FLAMETHROWER = 15;
|
|||||||
const int FIRE_SHOCKWAVE = 16;
|
const int FIRE_SHOCKWAVE = 16;
|
||||||
const int FIRE_BOWL = 17;
|
const int FIRE_BOWL = 17;
|
||||||
const int SNOW = 18;
|
const int SNOW = 18;
|
||||||
|
const int EXPLOSION = 19;
|
||||||
|
|
||||||
// meters per second squared (acceleration)
|
// meters per second squared (acceleration)
|
||||||
const float earth_gravity = 9.807;
|
const float earth_gravity = 9.807;
|
||||||
@ -132,14 +133,14 @@ vec3 perp_axis2(vec3 axis1, vec3 axis2) {
|
|||||||
return normalize(vec3(axis1.y * axis2.z - axis1.z * axis2.y, axis1.z * axis2.x - axis1.x * axis2.z, axis1.x * axis2.y - axis1.y * axis2.x));
|
return normalize(vec3(axis1.y * axis2.z - axis1.z * axis2.y, axis1.z * axis2.x - axis1.x * axis2.z, axis1.x * axis2.y - axis1.y * axis2.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 spiral_motion(vec3 line, float radius, float time_function) {
|
vec3 spiral_motion(vec3 line, float radius, float time_function, float frequency, float offset) {
|
||||||
vec3 axis2 = perp_axis1(line);
|
vec3 axis2 = perp_axis1(line);
|
||||||
vec3 axis3 = perp_axis2(line, axis2);
|
vec3 axis3 = perp_axis2(line, axis2);
|
||||||
|
|
||||||
return vec3(
|
return line * time_function + vec3(
|
||||||
radius * cos(time_function) * axis2.x + radius * sin(time_function) * axis3.x,
|
radius * cos(frequency * time_function - offset) * axis2.x + radius * sin(frequency * time_function - offset) * axis3.x,
|
||||||
radius * cos(time_function) * axis2.y + radius * sin(time_function) * axis3.y,
|
radius * cos(frequency * time_function - offset) * axis2.y + radius * sin(frequency * time_function - offset) * axis3.y,
|
||||||
radius * cos(time_function) * axis2.z + radius * sin(time_function) * axis3.z);
|
radius * cos(frequency * time_function - offset) * axis2.z + radius * sin(frequency * time_function - offset) * axis3.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -321,16 +322,16 @@ void main() {
|
|||||||
} else if (inst_mode == HEALING_BEAM) {
|
} else if (inst_mode == HEALING_BEAM) {
|
||||||
f_reflect = 0.0;
|
f_reflect = 0.0;
|
||||||
attr = Attr(
|
attr = Attr(
|
||||||
spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan),
|
spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan, 10.0, inst_time),
|
||||||
vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))),
|
vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))),
|
||||||
vec4(vec3(0.4, 2.7 + 0.4 * sin(tick.x * 8 - lifetime * 3 + 4), 0.5 + 0.6 * sin(tick.x * 7)), start_end(1.0, 0.0) /*0.3*/),
|
vec4(vec3(0.4, 1.6 + 0.3 * sin(tick.x * 10 - lifetime * 3 + 4), 1.0 + 0.15 * sin(tick.x * 5 - lifetime * 5)), start_end(1.0, 0.0) /*0.3*/),
|
||||||
spin_in_axis(inst_dir, tick.z)
|
spin_in_axis(inst_dir, tick.z)
|
||||||
);
|
);
|
||||||
} else if (inst_mode == ENERGY_NATURE) {
|
} else if (inst_mode == ENERGY_NATURE) {
|
||||||
f_reflect = 0.0;
|
f_reflect = 0.0;
|
||||||
attr = Attr(
|
attr = Attr(
|
||||||
inst_dir * slow_end(0.03) + spiral_motion(vec3(rand1, rand2, rand3),
|
inst_dir * slow_end(0.03) + spiral_motion(vec3(rand1, rand2, rand3),
|
||||||
0.2 * (rand4 + 1.3) * slow_end(0.02), percent() * 3 * (rand4 + 4.0) + rand0),
|
0.2 * (rand4 + 1.3) * slow_end(0.02), percent() * 3 * (rand4 + 4.0) + rand0, 1.0, 0.0),
|
||||||
vec3(1.0),
|
vec3(1.0),
|
||||||
vec4(vec3(0, 2.5, 1.5 + rand7 * 0.7), start_end(1.0, 0.0)),
|
vec4(vec3(0, 2.5, 1.5 + rand7 * 0.7), start_end(1.0, 0.0)),
|
||||||
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
|
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
|
||||||
@ -338,8 +339,15 @@ void main() {
|
|||||||
} else if (inst_mode == FLAMETHROWER) {
|
} else if (inst_mode == FLAMETHROWER) {
|
||||||
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
|
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
|
||||||
attr = Attr(
|
attr = Attr(
|
||||||
inst_dir * ((rand0+1.0)/2 + 0.5) * slow_end(0.2) + /*0.4 * vec3(rand0,
|
(inst_dir * slow_end(1.5)) + vec3(rand0, rand1, rand2) * (lifetime * 5 + 0.25),
|
||||||
rand1, rand2) * slow_end(0.1)*/ + 0.1 * grav_vel(earth_gravity),
|
vec3((2.5 * (1 - slow_start(0.3)))),
|
||||||
|
vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)),
|
||||||
|
spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9)
|
||||||
|
);
|
||||||
|
} else if (inst_mode == EXPLOSION) {
|
||||||
|
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
|
||||||
|
attr = Attr(
|
||||||
|
inst_dir * ((rand0+1.0)/2 + 0.5) * slow_end(0.2) + 0.1 * grav_vel(earth_gravity),
|
||||||
vec3((3 * (1 - slow_start(0.1)))),
|
vec3((3 * (1 - slow_start(0.1)))),
|
||||||
vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)),
|
vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)),
|
||||||
spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9)
|
spin_in_axis(vec3(rand6, rand7, rand8), percent() * 10 + 3 * rand9)
|
||||||
@ -347,9 +355,9 @@ void main() {
|
|||||||
} else if (inst_mode == FIRE_SHOCKWAVE) {
|
} else if (inst_mode == FIRE_SHOCKWAVE) {
|
||||||
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
|
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
|
||||||
attr = Attr(
|
attr = Attr(
|
||||||
vec3(rand0, rand1, lifetime * 1 + rand2),
|
vec3(rand0, rand1, lifetime * 10 + rand2),
|
||||||
vec3(1.6 + rand3 * 1.5 + 10 * (lifetime + inst_lifespan)),
|
vec3((5 * (1 - slow_start(0.5)))),
|
||||||
vec4(3, 1.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0.2, start_end(1.0, 0.0) /*0.8 - 3.5 * inst_lifespan*/),
|
vec4(3, 1.6 + rand5 * 0.3 - 0.4 * percent(), 0.2, start_end(1.0, 0.0)),
|
||||||
spin_in_axis(vec3(rand3, rand4, rand5), rand6)
|
spin_in_axis(vec3(rand3, rand4, rand5), rand6)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -115,6 +115,7 @@ pub enum ParticleMode {
|
|||||||
FireShockwave = 16,
|
FireShockwave = 16,
|
||||||
FireBowl = 17,
|
FireBowl = 17,
|
||||||
Snow = 18,
|
Snow = 18,
|
||||||
|
Explosion = 19,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParticleMode {
|
impl ParticleMode {
|
||||||
|
@ -64,10 +64,10 @@ impl ParticleMgr {
|
|||||||
if *is_attack {
|
if *is_attack {
|
||||||
if *power < 0.0 {
|
if *power < 0.0 {
|
||||||
self.particles.resize_with(
|
self.particles.resize_with(
|
||||||
self.particles.len() + (200.0 * power.abs()) as usize,
|
self.particles.len() + (60.0 * power.abs()) as usize,
|
||||||
|| {
|
|| {
|
||||||
Particle::new_directed(
|
Particle::new_directed(
|
||||||
Duration::from_secs_f32(rng.gen_range(1.0..8.0)),
|
Duration::from_secs_f32(rng.gen_range(0.2..3.0)),
|
||||||
time,
|
time,
|
||||||
ParticleMode::EnergyNature,
|
ParticleMode::EnergyNature,
|
||||||
*pos,
|
*pos,
|
||||||
@ -80,12 +80,12 @@ impl ParticleMgr {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self.particles.resize_with(
|
self.particles.resize_with(
|
||||||
self.particles.len() + (200.0 * power.abs()) as usize,
|
self.particles.len() + (75.0 * power.abs()) as usize,
|
||||||
|| {
|
|| {
|
||||||
Particle::new_directed(
|
Particle::new_directed(
|
||||||
Duration::from_secs(2),
|
Duration::from_millis(500),
|
||||||
time,
|
time,
|
||||||
ParticleMode::FlameThrower,
|
ParticleMode::Explosion,
|
||||||
*pos,
|
*pos,
|
||||||
*pos + Vec3::<f32>::zero()
|
*pos + Vec3::<f32>::zero()
|
||||||
.map(|_| rng.gen_range(-1.0..1.0))
|
.map(|_| rng.gen_range(-1.0..1.0))
|
||||||
@ -642,7 +642,7 @@ impl ParticleMgr {
|
|||||||
let theta = ori_vec.y.atan2(ori_vec.x);
|
let theta = ori_vec.y.atan2(ori_vec.x);
|
||||||
let dtheta = radians / distance;
|
let dtheta = radians / distance;
|
||||||
|
|
||||||
let heartbeats = self.scheduler.heartbeats(Duration::from_millis(1));
|
let heartbeats = self.scheduler.heartbeats(Duration::from_millis(5));
|
||||||
|
|
||||||
for heartbeat in 0..heartbeats {
|
for heartbeat in 0..heartbeats {
|
||||||
if shockwave.properties.requires_ground {
|
if shockwave.properties.requires_ground {
|
||||||
@ -667,28 +667,25 @@ impl ParticleMgr {
|
|||||||
|
|
||||||
let position_snapped = ((position / scale).floor() + 0.5) * scale;
|
let position_snapped = ((position / scale).floor() + 0.5) * scale;
|
||||||
|
|
||||||
self.particles.push(Particle::new_directed(
|
self.particles.push(Particle::new(
|
||||||
Duration::from_secs(2),
|
Duration::from_millis(250),
|
||||||
time,
|
time,
|
||||||
ParticleMode::GroundShockwave,
|
ParticleMode::GroundShockwave,
|
||||||
position_snapped,
|
position_snapped,
|
||||||
Vec3::new(0.0, 0.0, 10.0) + position_snapped,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for d in 0..8 * distance as i32 {
|
for d in 0..3 * distance as i32 {
|
||||||
let arc_position = theta - radians / 2.0 + dtheta * d as f32 / 3.0;
|
let arc_position = theta - radians / 2.0 + dtheta * d as f32 / 3.0;
|
||||||
|
|
||||||
let diff =
|
let position = pos.0
|
||||||
distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0);
|
+ distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0);
|
||||||
let position = pos.0 + diff;
|
|
||||||
|
|
||||||
self.particles.push(Particle::new_directed(
|
self.particles.push(Particle::new(
|
||||||
Duration::from_millis(500),
|
Duration::from_secs_f32((distance + 10.0) / 50.0),
|
||||||
time,
|
time,
|
||||||
ParticleMode::FlameThrower,
|
ParticleMode::FireShockwave,
|
||||||
pos.0 + diff * 0.9,
|
position,
|
||||||
Vec3::new(0.0, 0.0, 2.0) + position,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user