Merge remote-tracking branch 'origin/master' into zesterer/lod

This commit is contained in:
Joshua Yanovski 2020-04-03 05:01:41 +02:00
commit f6fc9307a1
12 changed files with 86 additions and 49 deletions

18
Cargo.lock generated
View File

@ -331,9 +331,13 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]] [[package]]
name = "bitvec" name = "bitvec"
version = "0.15.2" version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c"
dependencies = [
"either",
"radium",
]
[[package]] [[package]]
name = "blake2b_simd" name = "blake2b_simd"
@ -410,9 +414,9 @@ dependencies = [
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.2.0" version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742" checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
@ -3401,6 +3405,12 @@ dependencies = [
"proc-macro2 1.0.9", "proc-macro2 1.0.9",
] ]
[[package]]
name = "radium"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.4.6" version = "0.4.6"

View File

@ -191,6 +191,19 @@ Bu pencereyi kapatmak için imlecini serbest bırakmak mı istiyorsun? TAB'a bas
Veloren'in Dünyasında sana iyi eğlenceler!"#, Veloren'in Dünyasında sana iyi eğlenceler!"#,
// Inventory
"hud.bag.inventory": "'in Envanteri",
"hud.bag.stats_title": "'in Nitelikleri",
"hud.bag.exp": "Tecrübe",
"hud.bag.armor": "Zırh",
"hud.bag.stats": "Nitelikler",
// Map and Questlog
"hud.map.map_title": "Harita",
"hud.map.qlog_title": "Görevler",
// Settings
"hud.settings.general": "Genel", "hud.settings.general": "Genel",
"hud.settings.none": "Yok", "hud.settings.none": "Yok",
"hud.settings.press_behavior.toggle": "Aç/kapa", "hud.settings.press_behavior.toggle": "Aç/kapa",
@ -203,7 +216,7 @@ Veloren'in Dünyasında sana iyi eğlenceler!"#,
"hud.settings.custom_scaling": "Özel Ölçek", "hud.settings.custom_scaling": "Özel Ölçek",
"hud.settings.crosshair": "İmleç tipi", "hud.settings.crosshair": "İmleç tipi",
"hud.settings.transparency": "Şeffaflık", "hud.settings.transparency": "Şeffaflık",
"hud.settings.hotbar": "Hotbar", "hud.settings.hotbar": "Aksiyon Çubuğu",
"hud.settings.toggle_shortcuts": "Kısayolları aç/kapa", "hud.settings.toggle_shortcuts": "Kısayolları aç/kapa",
"hud.settings.toggle_bar_experience": "Tecrübe çubuğunu aç/kapa", "hud.settings.toggle_bar_experience": "Tecrübe çubuğunu aç/kapa",
"hud.settings.scrolling_combat_text": "Verilen/Alınan Hasar Yazısı", "hud.settings.scrolling_combat_text": "Verilen/Alınan Hasar Yazısı",
@ -371,7 +384,7 @@ silmek istediğinden emin misin?"#,
// Charater stats // Charater stats
"character_window.character_stats": r#"Dayanıklılık "character_window.character_stats": r#"Dayanıklılık
Fiziksel yetenek Hareket gücü
İrade gücü İrade gücü
"#, "#,

View File

@ -19,8 +19,8 @@ use std::{
/// The error returned by asset loading functions /// The error returned by asset loading functions
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Error { pub enum Error {
/// An internal error occurred. /// Parsing error occurred.
Internal(Arc<dyn std::error::Error>), ParseError(Arc<dyn std::fmt::Debug>),
/// An asset of a different type has already been loaded with this /// An asset of a different type has already been loaded with this
/// specifier. /// specifier.
InvalidType, InvalidType,
@ -28,10 +28,16 @@ pub enum Error {
NotFound(String), NotFound(String),
} }
impl Error {
pub fn parse_error<E: std::fmt::Debug + 'static>(err: E) -> Self {
Self::ParseError(Arc::new(err))
}
}
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Error::Internal(err) => err.fmt(f), Error::ParseError(err) => write!(f, "{:?}", err),
Error::InvalidType => write!( Error::InvalidType => write!(
f, f,
"an asset of a different type has already been loaded with this specifier." "an asset of a different type has already been loaded with this specifier."
@ -110,7 +116,16 @@ pub fn load_glob<A: Asset + 'static>(specifier: &str) -> Result<Arc<Vec<Arc<A>>>
let assets = Arc::new( let assets = Arc::new(
glob_matches glob_matches
.into_iter() .into_iter()
.filter_map(|name| load(&specifier.replace("*", &name)).ok()) .filter_map(|name| {
load(&specifier.replace("*", &name))
.map_err(|e| {
error!(
"Failed to load \"{}\" as part of glob \"{}\" with error: {:?}",
name, specifier, e
)
})
.ok()
})
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
); );
let clone = Arc::clone(&assets); let clone = Arc::clone(&assets);
@ -226,7 +241,7 @@ impl Asset for DynamicImage {
fn parse(mut buf_reader: BufReader<File>) -> Result<Self, Error> { fn parse(mut buf_reader: BufReader<File>) -> Result<Self, Error> {
let mut buf = Vec::new(); let mut buf = Vec::new();
buf_reader.read_to_end(&mut buf)?; buf_reader.read_to_end(&mut buf)?;
Ok(image::load_from_memory(&buf).unwrap()) image::load_from_memory(&buf).map_err(Error::parse_error)
} }
} }
@ -236,7 +251,7 @@ impl Asset for DotVoxData {
fn parse(mut buf_reader: BufReader<File>) -> Result<Self, Error> { fn parse(mut buf_reader: BufReader<File>) -> Result<Self, Error> {
let mut buf = Vec::new(); let mut buf = Vec::new();
buf_reader.read_to_end(&mut buf)?; buf_reader.read_to_end(&mut buf)?;
Ok(dot_vox::load_bytes(&buf).unwrap()) dot_vox::load_bytes(&buf).map_err(Error::parse_error)
} }
} }
@ -245,7 +260,7 @@ impl Asset for Value {
const ENDINGS: &'static [&'static str] = &["json"]; const ENDINGS: &'static [&'static str] = &["json"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, Error> {
Ok(serde_json::from_reader(buf_reader).unwrap()) serde_json::from_reader(buf_reader).map_err(Error::parse_error)
} }
} }

View File

@ -16,7 +16,7 @@ use crate::{
}; };
use specs::{Component, FlaggedStorage}; use specs::{Component, FlaggedStorage};
use specs_idvs::IDVStorage; use specs_idvs::IDVStorage;
use std::{fs::File, io::BufReader, sync::Arc}; use std::{fs::File, io::BufReader};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)] #[repr(u32)]
@ -84,7 +84,7 @@ impl<
const ENDINGS: &'static [&'static str] = &["json"]; const ENDINGS: &'static [&'static str] = &["json"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
serde_json::de::from_reader(buf_reader).map_err(|e| assets::Error::Internal(Arc::new(e))) serde_json::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }

View File

@ -75,7 +75,7 @@ impl Asset for Item {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).unwrap()) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }

View File

@ -98,17 +98,14 @@ impl MovementEventMapper {
Some(Self::get_volume_for_body_type(body)), Some(Self::get_volume_for_body_type(body)),
)); ));
// Set the new previous entity state
state.event = mapped_event;
state.time = Instant::now(); state.time = Instant::now();
}
// update state to determine the next event. We only record the time (above) if
// it was dispatched
state.event = mapped_event;
state.weapon_drawn = Self::weapon_drawn(character); state.weapon_drawn = Self::weapon_drawn(character);
state.on_ground = physics.on_ground; state.on_ground = physics.on_ground;
} else {
// If we don't dispatch the event, store this data as we can use it to determine
// the next event
state.event = mapped_event;
state.on_ground = physics.on_ground;
}
} }
} }

View File

@ -78,7 +78,7 @@ impl Asset for ItemImagesSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing item images spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }

View File

@ -108,7 +108,8 @@ impl Asset for VoxygenLocalization {
/// Load the translations located in the input buffer and convert them /// Load the translations located in the input buffer and convert them
/// into a `VoxygenLocalization` object. /// into a `VoxygenLocalization` object.
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
let mut asked_localization: VoxygenLocalization = from_reader(buf_reader).unwrap(); let mut asked_localization: VoxygenLocalization =
from_reader(buf_reader).map_err(assets::Error::parse_error)?;
// Update the text if UTF-8 to ASCII conversion is enabled // Update the text if UTF-8 to ASCII conversion is enabled
if asked_localization.convert_utf8_to_ascii { if asked_localization.convert_utf8_to_ascii {

View File

@ -139,7 +139,7 @@ impl Asset for HumHeadSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid head spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -261,49 +261,49 @@ impl Asset for HumArmorShoulderSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor shoulder spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumArmorChestSpec { impl Asset for HumArmorChestSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor chest spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumArmorHandSpec { impl Asset for HumArmorHandSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor hand spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumArmorBeltSpec { impl Asset for HumArmorBeltSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor belt spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumArmorPantsSpec { impl Asset for HumArmorPantsSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor pants spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumArmorFootSpec { impl Asset for HumArmorFootSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor foot spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
impl Asset for HumMainWeaponSpec { impl Asset for HumMainWeaponSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid main weapon spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -667,7 +667,7 @@ impl Asset for QuadrupedSmallCentralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing quad_small central spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -675,7 +675,7 @@ impl Asset for QuadrupedSmallLateralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped small lateral spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -828,7 +828,7 @@ impl Asset for QuadrupedMediumCentralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped medium central spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -836,7 +836,7 @@ impl Asset for QuadrupedMediumLateralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped medium lateral spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -1074,7 +1074,7 @@ impl Asset for BirdMediumCenterSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing bird medium center spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -1082,7 +1082,7 @@ impl Asset for BirdMediumLateralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing bird medium lateral spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -1232,7 +1232,7 @@ impl Asset for CritterCenterSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing critter center spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -1587,7 +1587,7 @@ impl Asset for BipedLargeCenterSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing biped large center spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }
@ -1595,7 +1595,7 @@ impl Asset for BipedLargeLateralSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing biped large lateral spec")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }

View File

@ -7,7 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
bincode = "1.2.0" bincode = "1.2.0"
common = { package = "veloren-common", path = "../common" } common = { package = "veloren-common", path = "../common" }
bitvec = "0.15.2" bitvec = "0.17.4"
image = "0.22.3" image = "0.22.3"
itertools = "0.8.2" itertools = "0.8.2"
vek = "0.10.0" vek = "0.10.0"

View File

@ -87,7 +87,7 @@ impl Asset for StructuresSpec {
const ENDINGS: &'static [&'static str] = &["ron"]; const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> { fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
Ok(ron::de::from_reader(buf_reader).expect("Error parsing structure specs")) ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
} }
} }

View File

@ -1,5 +1,5 @@
use super::WORLD_SIZE; use super::WORLD_SIZE;
use bitvec::prelude::{bitbox, bitvec, BitBox}; use bitvec::prelude::{bitbox, BitBox};
use common::{terrain::TerrainChunkSize, vol::RectVolSize}; use common::{terrain::TerrainChunkSize, vol::RectVolSize};
use noise::{MultiFractal, NoiseFn, Perlin, Point2, Point3, Point4, Seedable}; use noise::{MultiFractal, NoiseFn, Perlin, Point2, Point3, Point4, Seedable};
use num::Float; use num::Float;
@ -322,10 +322,11 @@ pub fn get_oceans<F: Float>(oldh: impl Fn(usize) -> F + Sync) -> BitBox {
while let Some(chunk_idx) = stack.pop() { while let Some(chunk_idx) = stack.pop() {
// println!("Ocean chunk {:?}: {:?}", uniform_idx_as_vec2(chunk_idx), // println!("Ocean chunk {:?}: {:?}", uniform_idx_as_vec2(chunk_idx),
// oldh(chunk_idx)); // oldh(chunk_idx));
if *is_ocean.at(chunk_idx) { let mut is_ocean = is_ocean.get_mut(chunk_idx).unwrap();
if *is_ocean {
continue; continue;
} }
*is_ocean.at(chunk_idx) = true; *is_ocean = true;
stack.extend(neighbors(chunk_idx).filter(|&neighbor_idx| { stack.extend(neighbors(chunk_idx).filter(|&neighbor_idx| {
// println!("Ocean neighbor: {:?}: {:?}", uniform_idx_as_vec2(neighbor_idx), // println!("Ocean neighbor: {:?}: {:?}", uniform_idx_as_vec2(neighbor_idx),
// oldh(neighbor_idx)); // oldh(neighbor_idx));