mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed comments and fixed pipeline
This commit is contained in:
parent
3b47add55a
commit
2d2f267907
@ -2,7 +2,7 @@
|
||||
tracks: [
|
||||
(
|
||||
path: "voxygen.audio.ambient.wind",
|
||||
length: 4.5,
|
||||
length: 14.5,
|
||||
tag: Wind,
|
||||
),
|
||||
]
|
||||
|
BIN
assets/voxygen/audio/ambient/wind.ogg
(Stored with Git LFS)
BIN
assets/voxygen/audio/ambient/wind.ogg
(Stored with Git LFS)
Binary file not shown.
@ -102,32 +102,32 @@
|
||||
],
|
||||
threshold: 0.12,
|
||||
),
|
||||
ExperienceGained: (
|
||||
files: [
|
||||
// "voxygen.audio.sfx.character.experience_gained_1",
|
||||
// "voxygen.audio.sfx.character.experience_gained_2",
|
||||
// "voxygen.audio.sfx.character.experience_gained_3",
|
||||
],
|
||||
threshold: 0.5,
|
||||
),
|
||||
//ExperienceGained: (
|
||||
// files: [
|
||||
// "voxygen.audio.sfx.character.experience_gained_1",
|
||||
// "voxygen.audio.sfx.character.experience_gained_2",
|
||||
// "voxygen.audio.sfx.character.experience_gained_3",
|
||||
// ],
|
||||
// threshold: 0.5,
|
||||
//),
|
||||
LevelUp:(
|
||||
files: [
|
||||
"voxygen.audio.sfx.character.level_up_sound_-_shorter_wind_up",
|
||||
],
|
||||
threshold: 0.5,
|
||||
),
|
||||
Jump: (
|
||||
files: [
|
||||
// Event not implemented?
|
||||
],
|
||||
threshold: 0.25,
|
||||
),
|
||||
Fall: (
|
||||
files: [
|
||||
// Event not implemented?
|
||||
],
|
||||
threshold: 0.25,
|
||||
),
|
||||
//Jump: (
|
||||
// files: [
|
||||
// // Event not implemented?
|
||||
// ],
|
||||
// threshold: 0.25,
|
||||
//),
|
||||
//Fall: (
|
||||
// files: [
|
||||
// // Event not implemented?
|
||||
// ],
|
||||
// threshold: 0.25,
|
||||
//),
|
||||
Roll: (
|
||||
files: [
|
||||
"voxygen.audio.sfx.character.dive_roll_1",
|
||||
@ -135,18 +135,18 @@
|
||||
],
|
||||
threshold: 0.25,
|
||||
),
|
||||
Climb: (
|
||||
files: [
|
||||
// TODO: sync with animation
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_1",
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_2",
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_3",
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_4",
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_5",
|
||||
//"voxygen.audio.sfx.footsteps.stepgrass_6",
|
||||
],
|
||||
threshold: 0.25,
|
||||
),
|
||||
//Climb: (
|
||||
// files: [
|
||||
// TODO: sync with animation
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_1",
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_2",
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_3",
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_4",
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_5",
|
||||
// "voxygen.audio.sfx.footsteps.stepgrass_6",
|
||||
// ],
|
||||
// threshold: 0.25,
|
||||
//),
|
||||
GliderOpen: (
|
||||
files: [
|
||||
"voxygen.audio.sfx.glider_open",
|
||||
@ -325,12 +325,12 @@
|
||||
],
|
||||
threshold: 0.2,
|
||||
),
|
||||
Attack(BasicRanged, Staff): (
|
||||
files: [
|
||||
// "voxygen.audio.sfx.abilities.staff_channeling",
|
||||
],
|
||||
threshold: 0.8,
|
||||
),
|
||||
//Attack(BasicRanged, Staff): (
|
||||
// files: [
|
||||
// "voxygen.audio.sfx.abilities.staff_channeling",
|
||||
// ],
|
||||
// threshold: 0.8,
|
||||
//),
|
||||
Inventory(CollectedTool(Staff)): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.inventory.pickup_staff",
|
||||
@ -577,17 +577,17 @@
|
||||
],
|
||||
threshold: 0.3,
|
||||
),
|
||||
Explosion: (
|
||||
files: [
|
||||
// in code
|
||||
],
|
||||
threshold: 0.2,
|
||||
),
|
||||
ProjectileShot: (
|
||||
files: [
|
||||
// in code
|
||||
],
|
||||
threshold: 0.5,
|
||||
),
|
||||
//Explosion: (
|
||||
// files: [
|
||||
// // in code
|
||||
// ],
|
||||
// threshold: 0.2,
|
||||
//),
|
||||
//ProjectileShot: (
|
||||
// files: [
|
||||
// // in code
|
||||
// ],
|
||||
// threshold: 0.5,
|
||||
//),
|
||||
}
|
||||
)
|
||||
|
BIN
assets/voxygen/audio/sfx/ambient/fire.wav
(Stored with Git LFS)
BIN
assets/voxygen/audio/sfx/ambient/fire.wav
(Stored with Git LFS)
Binary file not shown.
@ -8,6 +8,18 @@
|
||||
|
||||
(
|
||||
tracks: [
|
||||
(
|
||||
title: "Oceania",
|
||||
path: "voxygen.audio.soundtrack.oceania",
|
||||
length: 135.0,
|
||||
timing: None,
|
||||
biomes: [
|
||||
(Lake, 2),
|
||||
(Ocean, 3),
|
||||
],
|
||||
site: Some(Void),
|
||||
artist: "Eden",
|
||||
),
|
||||
(
|
||||
title: "A Solemn Quest",
|
||||
path: "voxygen.audio.soundtrack.a_solemn_quest",
|
||||
|
BIN
assets/voxygen/audio/soundtrack/oceania.ogg
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/soundtrack/oceania.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -4,10 +4,11 @@ use crate::{
|
||||
scene::Camera,
|
||||
};
|
||||
use client::Client;
|
||||
use common::{assets, state::State, terrain::BlockKind, vol::ReadVol};
|
||||
use common::{assets, state::State, vol::ReadVol};
|
||||
use serde::Deserialize;
|
||||
use std::time::Instant;
|
||||
use tracing::warn;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
struct AmbientCollection {
|
||||
@ -20,6 +21,7 @@ pub struct AmbientItem {
|
||||
path: String,
|
||||
/// Length of the track in seconds
|
||||
length: f32,
|
||||
/// Specifies which ambient channel to play on
|
||||
tag: AmbientChannelTag,
|
||||
}
|
||||
|
||||
@ -57,31 +59,24 @@ impl AmbientMgr {
|
||||
let focus_off = camera.get_focus_pos().map(f32::trunc);
|
||||
let cam_pos = camera.dependents().cam_pos + focus_off;
|
||||
|
||||
let cam_alt = cam_pos.z;
|
||||
let terrain_alt = Self::get_current_terrain_alt(client);
|
||||
let (terrain_alt, tree_density) = if let Some(chunk) = client.current_chunk() {
|
||||
(chunk.meta().alt(), chunk.meta().tree_density())
|
||||
} else {
|
||||
(0.0, 0.0)
|
||||
};
|
||||
|
||||
// The following code is specifically for wind, as it is the only
|
||||
// non-positional ambient sound in the game. Others can be added
|
||||
// as seen fit.
|
||||
|
||||
let alt_multiplier = (cam_alt / 1200.0).abs();
|
||||
// Wind volume increases with altitude
|
||||
let alt_multiplier = (cam_pos.z / 1200.0).abs();
|
||||
|
||||
// Tree density factors into ambient volume. The more trees,
|
||||
// the less ambient
|
||||
let mut tree_multiplier = self.tree_multiplier;
|
||||
let new_tree_multiplier = if (cam_alt - terrain_alt) < 150.0 {
|
||||
1.0 - Self::get_current_tree_density(client)
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
|
||||
// Smooths tree_multiplier transitions between chunks
|
||||
if tree_multiplier < new_tree_multiplier {
|
||||
tree_multiplier += 0.001;
|
||||
} else if tree_multiplier > new_tree_multiplier {
|
||||
tree_multiplier -= 0.001;
|
||||
}
|
||||
self.tree_multiplier = tree_multiplier;
|
||||
// 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).powf(2.0)).min(1.0);
|
||||
|
||||
let mut volume_multiplier = alt_multiplier * self.tree_multiplier;
|
||||
|
||||
@ -89,36 +84,30 @@ impl AmbientMgr {
|
||||
if state
|
||||
.terrain()
|
||||
.get((cam_pos).map(|e| e.floor() as i32))
|
||||
.map(|b| b.kind())
|
||||
.unwrap_or(BlockKind::Air)
|
||||
== BlockKind::Water
|
||||
.map(|b| b.is_liquid())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
volume_multiplier *= 0.1;
|
||||
}
|
||||
if cam_pos.z < Self::get_current_terrain_alt(client) - 10.0 {
|
||||
if cam_pos.z < terrain_alt - 10.0 {
|
||||
volume_multiplier = 0.0;
|
||||
}
|
||||
|
||||
let target_volume = volume_multiplier.max(0.0).min(1.0);
|
||||
let target_volume = volume_multiplier.clamped(0.0, 1.0);
|
||||
|
||||
// Transitions the ambient sounds (more) smoothly
|
||||
self.volume = audio.get_ambient_volume();
|
||||
if self.volume < target_volume {
|
||||
audio.set_ambient_volume(self.volume + 0.001);
|
||||
} else if self.volume > target_volume {
|
||||
audio.set_ambient_volume(self.volume - 0.001);
|
||||
}
|
||||
audio.set_ambient_volume(Lerp::lerp(self.volume, target_volume, 0.01));
|
||||
|
||||
if self.began_playing.elapsed().as_secs_f32() > self.next_track_change {
|
||||
//let game_time = (state.get_time_of_day() as u64 % 86400) as u32;
|
||||
//let current_period_of_day = Self::get_current_day_period(game_time);
|
||||
|
||||
// Right now there is only wind non-positional sfx so it is always
|
||||
// selected. Modify this variable assignment when adding other non-
|
||||
// positional sfx
|
||||
let track = &self
|
||||
.soundtrack
|
||||
.tracks
|
||||
.iter()
|
||||
.filter(|track| track.tag == AmbientChannelTag::Wind)
|
||||
.next();
|
||||
.find(|track| track.tag == AmbientChannelTag::Wind);
|
||||
|
||||
if let Some(track) = track {
|
||||
self.began_playing = Instant::now();
|
||||
@ -130,21 +119,6 @@ impl AmbientMgr {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_terrain_alt(client: &Client) -> f32 {
|
||||
if let Some(chunk) = client.current_chunk() {
|
||||
chunk.meta().alt()
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_tree_density(client: &Client) -> f32 {
|
||||
match client.current_chunk() {
|
||||
Some(current_chunk) => current_chunk.meta().tree_density(),
|
||||
None => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
fn load_soundtrack_items() -> AmbientCollection {
|
||||
match assets::load_file("voxygen.audio.ambient", &["ron"]) {
|
||||
Ok(file) => match ron::de::from_reader(file) {
|
||||
|
@ -150,7 +150,7 @@ impl MusicMgr {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
// Adds a bit of randomness between plays
|
||||
let silence_between_tracks_seconds: f32 = rng.gen_range(15.0, 60.0);
|
||||
let silence_between_tracks_seconds: f32 = rng.gen_range(45.0, 120.0);
|
||||
|
||||
let game_time = (state.get_time_of_day() as u64 % 86400) as u32;
|
||||
let current_period_of_day = Self::get_current_day_period(game_time);
|
||||
|
@ -12,7 +12,7 @@ use common::{
|
||||
comp::Pos,
|
||||
spiral::Spiral2d,
|
||||
state::State,
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
terrain::TerrainChunk,
|
||||
vol::{ReadVol, RectRasterableVol},
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
@ -184,7 +184,7 @@ impl EventMapper for BlockEventMapper {
|
||||
let underwater = state
|
||||
.terrain()
|
||||
.get(cam_pos.map(|e| e.floor() as i32))
|
||||
.map(|b| b.kind() == BlockKind::Water)
|
||||
.map(|b| b.is_liquid())
|
||||
.unwrap_or(false);
|
||||
|
||||
let sfx_trigger_item = triggers.get_key_value(&sounds.sfx);
|
||||
@ -212,6 +212,14 @@ impl BlockEventMapper {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensures that:
|
||||
/// 1. An sfx.ron entry exists for an SFX event
|
||||
/// 2. The sfx has not been played since it's timeout threshold has elapsed,
|
||||
/// which prevents firing every tick
|
||||
/// Note that with so many blocks to choose from and different blocks being
|
||||
/// selected each time, this is not perfect, but does reduce the number of
|
||||
/// plays from blocks that have already emitted sfx and are stored in the
|
||||
/// BlockEventMapper history.
|
||||
fn should_emit(
|
||||
previous_state: &PreviousBlockState,
|
||||
sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>,
|
||||
|
@ -11,7 +11,7 @@ use client::Client;
|
||||
use common::{
|
||||
comp::{object, Body, Pos},
|
||||
state::State,
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
terrain::TerrainChunk,
|
||||
vol::ReadVol,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
@ -69,7 +69,7 @@ impl EventMapper for CampfireEventMapper {
|
||||
let underwater = state
|
||||
.terrain()
|
||||
.get(cam_pos.map(|e| e.floor() as i32))
|
||||
.map(|b| b.kind() == BlockKind::Water)
|
||||
.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);
|
||||
|
@ -12,7 +12,7 @@ use client::Client;
|
||||
use common::{
|
||||
comp::{item::ItemKind, CharacterAbilityType, CharacterState, Loadout, Pos},
|
||||
state::State,
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
terrain::TerrainChunk,
|
||||
vol::ReadVol,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
@ -75,7 +75,7 @@ impl EventMapper for CombatEventMapper {
|
||||
let underwater = state
|
||||
.terrain()
|
||||
.get(cam_pos.map(|e| e.floor() as i32))
|
||||
.map(|b| b.kind() == BlockKind::Water)
|
||||
.map(|b| b.is_liquid())
|
||||
.unwrap_or(false);
|
||||
|
||||
let sfx_trigger_item = triggers.get_key_value(&mapped_event);
|
||||
|
@ -101,7 +101,7 @@ impl EventMapper for MovementEventMapper {
|
||||
let underwater = state
|
||||
.terrain()
|
||||
.get(cam_pos.map(|e| e.floor() as i32))
|
||||
.map(|b| b.kind() == BlockKind::Water)
|
||||
.map(|b| b.is_liquid())
|
||||
.unwrap_or(false);
|
||||
|
||||
let sfx_trigger_item = triggers.get_key_value(&mapped_event);
|
||||
|
Loading…
Reference in New Issue
Block a user