From f537f82b1720cf723cba88987800d1af1ad379fe Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 3 Mar 2021 19:20:48 +0000 Subject: [PATCH] Updated vek, fixed house wall bugs --- voxygen/Cargo.toml | 2 +- voxygen/anim/src/vek.rs | 8 ++--- voxygen/src/scene/math.rs | 5 ++- world/src/lib.rs | 4 +-- world/src/site2/plot/house.rs | 64 +++++++++++++++++++---------------- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 7002bac3f6..beb4070daa 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -16,7 +16,7 @@ simd = ["vek/platform_intrinsics"] tracy = ["tracing-tracy", "common/tracy"] plugins = ["client/plugins"] -default = ["gl", "singleplayer", "native-dialog", "plugins", "simd"] +default = ["gl", "singleplayer", "native-dialog", "plugins"]#, "simd"] [dependencies] client = {package = "veloren-client", path = "../client"} diff --git a/voxygen/anim/src/vek.rs b/voxygen/anim/src/vek.rs index ee9bda3c45..b7c1660f8d 100644 --- a/voxygen/anim/src/vek.rs +++ b/voxygen/anim/src/vek.rs @@ -1,8 +1,8 @@ -pub use ::vek::{ +/*pub use ::vek::{ bezier::repr_simd::*, geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, quaternion::repr_simd::*, transform::repr_simd::*, transition::*, vec::repr_simd::*, -}; -/* pub use ::vek::{ +}; */ +pub use ::vek::{ bezier::repr_c::*, geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, quaternion::repr_c::*, transform::repr_c::*, transition::*, vec::repr_c::*, -}; */ +}; diff --git a/voxygen/src/scene/math.rs b/voxygen/src/scene/math.rs index 7f21fac5f5..26e7543c9a 100644 --- a/voxygen/src/scene/math.rs +++ b/voxygen/src/scene/math.rs @@ -1,9 +1,8 @@ use core::{iter, mem}; use hashbrown::HashMap; use num::traits::Float; -pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*}; -// pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, -// vec::repr_c::*}; +// pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*}; +pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, vec::repr_c::*}; pub fn aabb_to_points(bounds: Aabb) -> [Vec3; 8] { [ diff --git a/world/src/lib.rs b/world/src/lib.rs index 6a90f4c34a..c9ad01cb98 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -10,7 +10,7 @@ label_break_value, or_patterns, array_value_iter, - array_map, + array_map )] mod all; @@ -32,8 +32,8 @@ pub mod util; // Reexports pub use crate::{ canvas::{Canvas, CanvasInfo}, - land::Land, config::CONFIG, + land::Land, }; pub use block::BlockGen; pub use column::ColumnSample; diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index 89e92e3ae0..425800709c 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -1,8 +1,8 @@ use super::*; -use crate::{Land, util::SQUARE_4}; +use crate::{util::SQUARE_4, Land}; use common::terrain::{Block, BlockKind, SpriteKind}; -use vek::*; use rand::prelude::*; +use vek::*; pub struct House { door_tile: Vec2, @@ -13,7 +13,13 @@ pub struct House { } impl House { - pub fn generate(land: &Land, rng: &mut impl Rng, site: &Site, door_tile: Vec2, tile_aabr: Aabr) -> Self { + pub fn generate( + land: &Land, + rng: &mut impl Rng, + site: &Site, + door_tile: Vec2, + tile_aabr: Aabr, + ) -> Self { Self { door_tile, tile_aabr, @@ -40,12 +46,12 @@ impl Structure for House { // Walls let outer = prim(Primitive::Aabb(Aabb { - min: Vec3::new(self.bounds.min.x, self.bounds.min.y, self.alt - foundations), - max: Vec3::new(self.bounds.max.x, self.bounds.max.y, self.alt + roof), + min: self.bounds.min.with_z(self.alt - foundations), + max: (self.bounds.max + 1).with_z(self.alt + roof), })); let inner = prim(Primitive::Aabb(Aabb { - min: Vec3::new(self.bounds.min.x + 1, self.bounds.min.y + 1, self.alt + 0), - max: Vec3::new(self.bounds.max.x - 1, self.bounds.max.y - 1, self.alt + roof), + min: (self.bounds.min + 1).with_z(self.alt), + max: self.bounds.max.with_z(self.alt + roof), })); let walls = prim(Primitive::Xor(outer, inner)); fill(Fill { @@ -57,16 +63,16 @@ impl Structure for House { let mut pillars_y = prim(Primitive::Empty); for x in self.tile_aabr.min.x..self.tile_aabr.max.x + 2 { let pillar = prim(Primitive::Aabb(Aabb { - min: Vec3::from(site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y))) + Vec3::unit_z() * self.alt, - max: Vec3::from(site.tile_wpos(Vec2::new(x, self.tile_aabr.max.y)) + Vec2::unit_x()) + Vec3::unit_z() * (self.alt + roof), + min: site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)).with_z(self.alt), + max: (site.tile_wpos(Vec2::new(x, self.tile_aabr.max.y + 1)) + Vec2::unit_x()).with_z(self.alt + roof), })); pillars_y = prim(Primitive::Or(pillars_y, pillar)); } let mut pillars_x = prim(Primitive::Empty); for y in self.tile_aabr.min.y..self.tile_aabr.max.y + 2 { let pillar = prim(Primitive::Aabb(Aabb { - min: Vec3::from(site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y))) + Vec3::unit_z() * self.alt, - max: Vec3::from(site.tile_wpos(Vec2::new(self.tile_aabr.max.x, y)) + Vec2::unit_y()) + Vec3::unit_z() * (self.alt + roof), + min: site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)).with_z(self.alt), + max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x + 1, y)) + Vec2::unit_y()).with_z(self.alt + roof), })); pillars_x = prim(Primitive::Or(pillars_x, pillar)); } @@ -85,16 +91,14 @@ impl Structure for House { let mut windows = prim(Primitive::Empty); for y in self.tile_aabr.min.y..self.tile_aabr.max.y { let window = prim(Primitive::Aabb(Aabb { - min: Vec3::from(site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)) + Vec2::unit_y() * 2) + Vec3::unit_z() * (self.alt + height + 2), - max: Vec3::from(site.tile_wpos(Vec2::new(self.tile_aabr.max.x, y + 1)) - Vec2::unit_y() * 1) + Vec3::unit_z() * (self.alt + height + 5), + min: (site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)) + Vec2::unit_y() * 2).with_z(self.alt + height + 2), + max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x, y + 1)) + Vec2::new(1, -1)).with_z(self.alt + height + 5), })); windows = prim(Primitive::Or(windows, window)); } fill(Fill { prim: prim(Primitive::And(walls, windows)), - block: Block::air(SpriteKind::Window1) - .with_ori(2) - .unwrap(), + block: Block::air(SpriteKind::Window1).with_ori(2).unwrap(), }); } // Windows y axis @@ -102,24 +106,22 @@ impl Structure for House { let mut windows = prim(Primitive::Empty); for x in self.tile_aabr.min.x..self.tile_aabr.max.x { let window = prim(Primitive::Aabb(Aabb { - min: Vec3::from(site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)) + Vec2::unit_x() * 2) + Vec3::unit_z() * (self.alt + height + 2), - max: Vec3::from(site.tile_wpos(Vec2::new(x + 1, self.tile_aabr.max.y)) - Vec2::unit_x() * 1) + Vec3::unit_z() * (self.alt + height + 5), + min: (site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)) + Vec2::unit_x() * 2).with_z(self.alt + height + 2), + max: (site.tile_wpos(Vec2::new(x + 1, self.tile_aabr.max.y)) + Vec2::new(-1, 1)).with_z(self.alt + height + 5), })); windows = prim(Primitive::Or(windows, window)); } fill(Fill { prim: prim(Primitive::And(walls, windows)), - block: Block::air(SpriteKind::Window1) - .with_ori(0) - .unwrap(), + block: Block::air(SpriteKind::Window1).with_ori(0).unwrap(), }); } // Floor fill(Fill { prim: prim(Primitive::Aabb(Aabb { - min: Vec3::new(self.bounds.min.x, self.bounds.min.y, self.alt + height + 0), - max: Vec3::new(self.bounds.max.x, self.bounds.max.y, self.alt + height + 1), + min: self.bounds.min.with_z(self.alt + height), + max: (self.bounds.max + 1).with_z(self.alt + height + 1), })), block: Block::new(BlockKind::Rock, Rgb::new(89, 44, 14)), }); @@ -137,16 +139,20 @@ impl Structure for House { // }); // } - let roof_lip = 3; - let roof_height = (self.bounds.min - self.bounds.max).map(|e| e.abs()).reduce_min() / 2 + roof_lip; + let roof_height = (self.bounds.min - self.bounds.max) + .map(|e| e.abs()) + .reduce_min() + / 2 + + roof_lip + + 1; // Roof fill(Fill { prim: prim(Primitive::Pyramid { aabb: Aabb { - min: Vec3::new(self.bounds.min.x - roof_lip, self.bounds.min.y - roof_lip, self.alt + roof), - max: Vec3::new(self.bounds.max.x + roof_lip, self.bounds.max.y + roof_lip, self.alt + roof + roof_height), + min: (self.bounds.min - roof_lip).with_z(self.alt + roof), + max: (self.bounds.max + 1 + roof_lip).with_z(self.alt + roof + roof_height), }, inset: roof_height, }), @@ -156,8 +162,8 @@ impl Structure for House { // Foundations fill(Fill { prim: prim(Primitive::Aabb(Aabb { - min: Vec3::new(self.bounds.min.x - 1, self.bounds.min.y - 1, self.alt - foundations), - max: Vec3::new(self.bounds.max.x + 1, self.bounds.max.y + 1, self.alt + 1), + min: (self.bounds.min - 1).with_z(self.alt - foundations), + max: (self.bounds.max + 2).with_z(self.alt + 1), })), block: Block::new(BlockKind::Rock, Rgb::new(31, 33, 32)), });