Skip to content

Commit 21b8035

Browse files
authored
Fix possibly negative pspew value init (#7541)
* Fix possibly negative pspew value init * fix math
1 parent fd2ebaf commit 21b8035

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

code/weapon/weapons.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,11 @@ static particle::ParticleEffectHandle convertLegacyPspewBuffer(const pspew_legac
699699

700700
auto vel_vol_temp = std::make_unique<particle::PointVolume>();
701701
vel_vol_temp->posOffset = vec3d {{{pspew_buffer.particle_spew_scale, 0.f, 0.f}}};
702-
vel_vol_temp->m_modular_curves.add_curve("Time Running", particle::PointVolume::VolumeModularCurveOutput::OFFSET_ROT, modular_curves_entry{curve_id, ::util::UniformFloatRange(1.f), ::util::UniformFloatRange(0.f, 1.f / pspew_buffer.particle_spew_rotation_rate), true});
702+
float rot_rnd_min = 0.f;
703+
float rot_rnd_max = 1.0f / pspew_buffer.particle_spew_rotation_rate;
704+
if (rot_rnd_max < rot_rnd_min)
705+
std::swap(rot_rnd_min, rot_rnd_max);
706+
vel_vol_temp->m_modular_curves.add_curve("Time Running", particle::PointVolume::VolumeModularCurveOutput::OFFSET_ROT, modular_curves_entry{curve_id, ::util::UniformFloatRange(1.f), ::util::UniformFloatRange(rot_rnd_min, rot_rnd_max), true});
703707
velocity_vol = std::move(vel_vol_temp);
704708
}
705709
break;

0 commit comments

Comments
 (0)