mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'imbris/audio-fixes' into 'master'
Stop unbounded wind volume when zooming out, make campfires quieter Closes #844 See merge request veloren/veloren!1566
This commit is contained in:
commit
9065d0ca02
@ -69,14 +69,16 @@ impl AmbientMgr {
|
||||
// non-positional ambient sound in the game. Others can be added
|
||||
// as seen fit.
|
||||
|
||||
let target_volume = {
|
||||
// Wind volume increases with altitude
|
||||
let alt_multiplier = (cam_pos.z / 1200.0).abs();
|
||||
|
||||
// Tree density factors into wind volume. The more trees,
|
||||
// the lower wind volume. The trees make more of an impact
|
||||
// the closer the camera is to the ground.
|
||||
self.tree_multiplier =
|
||||
((1.0 - tree_density) + ((cam_pos.z - terrain_alt) / 150.0).powi(2)).min(1.0);
|
||||
self.tree_multiplier = ((1.0 - tree_density)
|
||||
+ ((cam_pos.z - terrain_alt).abs() / 150.0).powi(2))
|
||||
.min(1.0);
|
||||
|
||||
let mut volume_multiplier = alt_multiplier * self.tree_multiplier;
|
||||
|
||||
@ -93,7 +95,8 @@ impl AmbientMgr {
|
||||
volume_multiplier = 0.0;
|
||||
}
|
||||
|
||||
let target_volume = volume_multiplier.clamped(0.0, 1.0);
|
||||
volume_multiplier.clamped(0.0, 1.0)
|
||||
};
|
||||
|
||||
// Transitions the ambient sounds (more) smoothly
|
||||
self.volume = audio.get_ambient_volume();
|
||||
@ -113,7 +116,7 @@ impl AmbientMgr {
|
||||
self.began_playing = Instant::now();
|
||||
self.next_track_change = track.length;
|
||||
|
||||
audio.play_ambient(AmbientChannelTag::Wind, &track.path, volume_multiplier);
|
||||
audio.play_ambient(AmbientChannelTag::Wind, &track.path, target_volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,8 @@ impl EventMapper for CampfireEventMapper {
|
||||
.map(|b| b.is_liquid())
|
||||
.unwrap_or(false);
|
||||
let sfx_trigger_item = triggers.get_key_value(&mapped_event);
|
||||
audio.emit_sfx(sfx_trigger_item, pos.0, None, underwater);
|
||||
const CAMPFIRE_VOLUME: f32 = 0.1;
|
||||
audio.emit_sfx(sfx_trigger_item, pos.0, Some(CAMPFIRE_VOLUME), underwater);
|
||||
internal_state.time = Instant::now();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user