mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Stop unbounded wind volume when zooming out, make campfires quieter
This commit is contained in:
@ -69,14 +69,16 @@ impl AmbientMgr {
|
|||||||
// non-positional ambient sound in the game. Others can be added
|
// non-positional ambient sound in the game. Others can be added
|
||||||
// as seen fit.
|
// as seen fit.
|
||||||
|
|
||||||
|
let target_volume = {
|
||||||
// Wind volume increases with altitude
|
// Wind volume increases with altitude
|
||||||
let alt_multiplier = (cam_pos.z / 1200.0).abs();
|
let alt_multiplier = (cam_pos.z / 1200.0).abs();
|
||||||
|
|
||||||
// Tree density factors into wind volume. The more trees,
|
// Tree density factors into wind volume. The more trees,
|
||||||
// the lower wind volume. The trees make more of an impact
|
// the lower wind volume. The trees make more of an impact
|
||||||
// the closer the camera is to the ground.
|
// the closer the camera is to the ground.
|
||||||
self.tree_multiplier =
|
self.tree_multiplier = ((1.0 - tree_density)
|
||||||
((1.0 - tree_density) + ((cam_pos.z - terrain_alt) / 150.0).powi(2)).min(1.0);
|
+ ((cam_pos.z - terrain_alt).abs() / 150.0).powi(2))
|
||||||
|
.min(1.0);
|
||||||
|
|
||||||
let mut volume_multiplier = alt_multiplier * self.tree_multiplier;
|
let mut volume_multiplier = alt_multiplier * self.tree_multiplier;
|
||||||
|
|
||||||
@ -93,7 +95,8 @@ impl AmbientMgr {
|
|||||||
volume_multiplier = 0.0;
|
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
|
// Transitions the ambient sounds (more) smoothly
|
||||||
self.volume = audio.get_ambient_volume();
|
self.volume = audio.get_ambient_volume();
|
||||||
@ -113,7 +116,7 @@ impl AmbientMgr {
|
|||||||
self.began_playing = Instant::now();
|
self.began_playing = Instant::now();
|
||||||
self.next_track_change = track.length;
|
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())
|
.map(|b| b.is_liquid())
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
let sfx_trigger_item = triggers.get_key_value(&mapped_event);
|
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();
|
internal_state.time = Instant::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user