aboutsummaryrefslogtreecommitdiff
path: root/stockton-levels/src/traits
diff options
context:
space:
mode:
Diffstat (limited to 'stockton-levels/src/traits')
-rw-r--r--stockton-levels/src/traits/brushes.rs4
-rw-r--r--stockton-levels/src/traits/effects.rs8
-rw-r--r--stockton-levels/src/traits/entities.rs10
-rw-r--r--stockton-levels/src/traits/faces.rs14
-rw-r--r--stockton-levels/src/traits/light_maps.rs6
-rw-r--r--stockton-levels/src/traits/light_vols.rs4
-rw-r--r--stockton-levels/src/traits/mod.rs34
-rw-r--r--stockton-levels/src/traits/models.rs6
-rw-r--r--stockton-levels/src/traits/planes.rs10
-rw-r--r--stockton-levels/src/traits/textures.rs47
-rw-r--r--stockton-levels/src/traits/tree.rs14
-rw-r--r--stockton-levels/src/traits/vertices.rs13
-rw-r--r--stockton-levels/src/traits/visdata.rs16
13 files changed, 92 insertions, 94 deletions
diff --git a/stockton-levels/src/traits/brushes.rs b/stockton-levels/src/traits/brushes.rs
index 30ab420..a281394 100644
--- a/stockton-levels/src/traits/brushes.rs
+++ b/stockton-levels/src/traits/brushes.rs
@@ -39,6 +39,6 @@ pub struct BrushSide {
pub trait HasBrushes<S: CoordSystem>: HasPlanes<S> {
type BrushesIter<'a>: Iterator<Item = &'a Brush>;
- fn brushes_iter<'a>(&'a self) -> Self::BrushesIter<'a>;
- fn get_brush<'a>(&'a self, index: u32) -> &'a Brush;
+ fn brushes_iter(&self) -> Self::BrushesIter<'_>;
+ fn get_brush(&self, index: u32) -> &Brush;
}
diff --git a/stockton-levels/src/traits/effects.rs b/stockton-levels/src/traits/effects.rs
index dec2122..73f55bd 100644
--- a/stockton-levels/src/traits/effects.rs
+++ b/stockton-levels/src/traits/effects.rs
@@ -25,14 +25,12 @@ pub struct Effect {
pub name: String,
/// The brush used for this effect
- pub brush_idx: u32
-
- // todo: unknown: i32
+ pub brush_idx: u32, // todo: unknown: i32
}
pub trait HasEffects<S: CoordSystem>: HasBrushes<S> {
type EffectsIter<'a>: Iterator<Item = &'a Effect>;
- fn effects_iter<'a>(&'a self) -> Self::EffectsIter<'a>;
- fn get_effect<'a>(&'a self, index: u32) -> &'a Effect;
+ fn effects_iter(&self) -> Self::EffectsIter<'_>;
+ fn get_effect(&self, index: u32) -> &Effect;
}
diff --git a/stockton-levels/src/traits/entities.rs b/stockton-levels/src/traits/entities.rs
index 706f25a..e1370ed 100644
--- a/stockton-levels/src/traits/entities.rs
+++ b/stockton-levels/src/traits/entities.rs
@@ -1,4 +1,4 @@
-// Copyright (C) Oscar Shrimpton 2019
+// Copyright (C) Oscar Shrimpton 2019
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -13,8 +13,8 @@
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>.
-use std::iter::Iterator;
use std::collections::HashMap;
+use std::iter::Iterator;
#[derive(Debug, Clone, PartialEq)]
/// A game entity
@@ -23,7 +23,7 @@ pub struct Entity {
}
pub trait HasEntities {
- type EntitiesIter<'a>: Iterator<Item = &'a Entity>;
+ type EntitiesIter<'a>: Iterator<Item = &'a Entity>;
- fn entities_iter<'a>(&'a self) -> Self::EntitiesIter<'a>;
-} \ No newline at end of file
+ fn entities_iter(&self) -> Self::EntitiesIter<'_>;
+}
diff --git a/stockton-levels/src/traits/faces.rs b/stockton-levels/src/traits/faces.rs
index 50d2b7d..3b9fbdf 100644
--- a/stockton-levels/src/traits/faces.rs
+++ b/stockton-levels/src/traits/faces.rs
@@ -15,10 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with stockton-bsp. If not, see <http://www.gnu.org/licenses/>.
-use std::ops::Range;
use na::{Vector2, Vector3};
+use std::ops::Range;
-use super::{HasEffects, HasTextures, HasLightMaps, HasMeshVerts};
+use super::{HasEffects, HasLightMaps, HasMeshVerts, HasTextures};
use crate::coords::CoordSystem;
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -43,15 +43,17 @@ pub struct Face {
pub map_size: Vector2<u32>,
pub map_origin: Vector3<f32>,
pub map_vecs: [Vector3<f32>; 2],
-
+
pub normal: Vector3<f32>,
pub size: Vector2<u32>,
}
-pub trait HasFaces<S: CoordSystem>: HasTextures + HasEffects<S> + HasLightMaps + HasMeshVerts<S> {
+pub trait HasFaces<S: CoordSystem>:
+ HasTextures + HasEffects<S> + HasLightMaps + HasMeshVerts<S>
+{
type FacesIter<'a>: Iterator<Item = &'a Face>;
- fn faces_iter<'a>(&'a self) -> Self::FacesIter<'a>;
+ fn faces_iter(&self) -> Self::FacesIter<'_>;
fn faces_len(&self) -> u32;
- fn get_face<'a>(&'a self, index: u32) -> &'a Face;
+ fn get_face(&self, index: u32) -> &Face;
}
diff --git a/stockton-levels/src/traits/light_maps.rs b/stockton-levels/src/traits/light_maps.rs
index 9b30d91..59dc27f 100644
--- a/stockton-levels/src/traits/light_maps.rs
+++ b/stockton-levels/src/traits/light_maps.rs
@@ -57,6 +57,6 @@ impl fmt::Debug for LightMap {
pub trait HasLightMaps {
type LightMapsIter<'a>: Iterator<Item = &'a LightMap>;
- fn lightmaps_iter<'a>(&'a self) -> Self::LightMapsIter<'a>;
- fn get_lightmap<'a>(&'a self, index: u32) -> &'a LightMap;
-} \ No newline at end of file
+ fn lightmaps_iter(&self) -> Self::LightMapsIter<'_>;
+ fn get_lightmap(&self, index: u32) -> &LightMap;
+}
diff --git a/stockton-levels/src/traits/light_vols.rs b/stockton-levels/src/traits/light_vols.rs
index 8e75401..871f028 100644
--- a/stockton-levels/src/traits/light_vols.rs
+++ b/stockton-levels/src/traits/light_vols.rs
@@ -27,6 +27,6 @@ pub struct LightVol {
pub trait HasLightVols {
type LightVolsIter<'a>: Iterator<Item = &'a LightVol>;
- fn lightvols_iter<'a>(&'a self) -> Self::LightVolsIter<'a>;
- fn get_lightvol<'a>(&'a self, index: u32) -> &'a LightVol;
+ fn lightvols_iter(&self) -> Self::LightVolsIter<'_>;
+ fn get_lightvol(&self, index: u32) -> &LightVol;
}
diff --git a/stockton-levels/src/traits/mod.rs b/stockton-levels/src/traits/mod.rs
index 15bac30..3ee47b4 100644
--- a/stockton-levels/src/traits/mod.rs
+++ b/stockton-levels/src/traits/mod.rs
@@ -1,4 +1,4 @@
-// Copyright (C) Oscar Shrimpton 2019
+// Copyright (C) Oscar Shrimpton 2019
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -14,28 +14,28 @@
// with this program. If not, see <http://www.gnu.org/licenses/>.
//! Traits for parts of files that can exist
-pub mod visdata;
-pub mod entities;
-pub mod textures;
-pub mod planes;
-pub mod vertices;
-pub mod light_maps;
-pub mod light_vols;
pub mod brushes;
pub mod effects;
+pub mod entities;
pub mod faces;
-pub mod tree;
+pub mod light_maps;
+pub mod light_vols;
pub mod models;
+pub mod planes;
+pub mod textures;
+pub mod tree;
+pub mod vertices;
+pub mod visdata;
-pub use self::visdata::HasVisData;
-pub use self::textures::HasTextures;
-pub use self::entities::HasEntities;
-pub use self::planes::HasPlanes;
-pub use self::vertices::{HasVertices, HasMeshVerts};
-pub use self::light_maps::HasLightMaps;
-pub use self::light_vols::HasLightVols;
pub use self::brushes::HasBrushes;
pub use self::effects::HasEffects;
+pub use self::entities::HasEntities;
pub use self::faces::HasFaces;
+pub use self::light_maps::HasLightMaps;
+pub use self::light_vols::HasLightVols;
+pub use self::models::HasModels;
+pub use self::planes::HasPlanes;
+pub use self::textures::HasTextures;
pub use self::tree::HasBSPTree;
-pub use self::models::HasModels; \ No newline at end of file
+pub use self::vertices::{HasMeshVerts, HasVertices};
+pub use self::visdata::HasVisData;
diff --git a/stockton-levels/src/traits/models.rs b/stockton-levels/src/traits/models.rs
index 4f755f3..1f868ad 100644
--- a/stockton-levels/src/traits/models.rs
+++ b/stockton-levels/src/traits/models.rs
@@ -18,7 +18,7 @@
use na::Vector3;
use std::ops::Range;
-use super::{HasFaces, HasBrushes};
+use super::{HasBrushes, HasFaces};
use crate::coords::CoordSystem;
#[derive(Debug, Clone)]
@@ -32,6 +32,6 @@ pub struct Model {
pub trait HasModels<S: CoordSystem>: HasFaces<S> + HasBrushes<S> {
type ModelsIter<'a>: Iterator<Item = &'a Model>;
- fn models_iter<'a>(&'a self) -> Self::ModelsIter<'a>;
- fn get_model<'a>(&'a self, index: u32) -> &'a Model;
+ fn models_iter(&self) -> Self::ModelsIter<'_>;
+ fn get_model(&self, index: u32) -> &Model;
}
diff --git a/stockton-levels/src/traits/planes.rs b/stockton-levels/src/traits/planes.rs
index c024815..e827a31 100644
--- a/stockton-levels/src/traits/planes.rs
+++ b/stockton-levels/src/traits/planes.rs
@@ -15,9 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with rust-bsp. If not, see <http://www.gnu.org/licenses/>.
-use std::iter::Iterator;
-use na::Vector3;
use crate::coords::CoordSystem;
+use na::Vector3;
+use std::iter::Iterator;
/// The planes lump from a BSP file.
/// Found at lump index 2 in a q3 bsp.
@@ -39,6 +39,6 @@ pub struct Plane {
pub trait HasPlanes<S: CoordSystem> {
type PlanesIter<'a>: Iterator<Item = &'a Plane>;
- fn planes_iter<'a>(&'a self) -> Self::PlanesIter<'a>;
- fn get_plane<'a>(&'a self, idx: u32) -> &'a Plane;
-} \ No newline at end of file
+ fn planes_iter(&self) -> Self::PlanesIter<'_>;
+ fn get_plane(&self, idx: u32) -> &Plane;
+}
diff --git a/stockton-levels/src/traits/textures.rs b/stockton-levels/src/traits/textures.rs
index 16213ea..a9c9bc9 100644
--- a/stockton-levels/src/traits/textures.rs
+++ b/stockton-levels/src/traits/textures.rs
@@ -1,4 +1,4 @@
-// Copyright (C) Oscar Shrimpton 2019
+// Copyright (C) Oscar Shrimpton 2019
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -23,21 +23,20 @@ pub struct Texture {
pub contents: ContentsFlags,
}
-
bitflags!(
/// Extracted from the Q3 arena engine code.
/// https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/surfaceflags.h
pub struct SurfaceFlags: u32 {
/// never give falling damage
const NO_DAMAGE = 0x1;
-
+
/// affects game physics
const SLICK = 0x2;
-
+
/// lighting from environment map
const SKY = 0x4;
- /// don't make missile explosions
+ /// don't make missile explosions
const NO_IMPACT = 0x10;
/// function as a ladder
@@ -45,43 +44,43 @@ bitflags!(
/// don't leave missile marks
const NO_MARKS = 0x20;
-
+
/// make flesh sounds and effects
const FLESH = 0x40;
-
+
/// don't generate a drawsurface at all
const NODRAW = 0x80;
-
+
/// make a primary bsp splitter
const HINT = 0x01_00;
-
+
/// completely ignore, allowing non-closed brushes
const SKIP = 0x02_00;
-
+
/// surface doesn't need a lightmap
const NO_LIGHT_MAP = 0x04_00;
-
+
/// generate lighting info at vertexes
const POINT_LIGHT = 0x08_00;
-
+
/// clanking footsteps
const METAL_STEPS = 0x10_00;
-
+
/// no footstep sounds
const NO_STEPS = 0x20_00;
-
+
/// don't collide against curves with this set
const NON_SOLID = 0x40_00;
-
+
/// act as a light filter during q3map -light
const LIGHT_FILTER = 0x80_00;
-
+
/// do per-pixel light shadow casting in q3map
const ALPHA_SHADOW = 0x01_00_00;
-
+
/// don't dlight even if solid (solid lava, skies)
const NO_DLIGHT = 0x02_00_00;
-
+
/// leave a dust trail when walking on this surface
const DUST = 0x04_00_00;
}
@@ -116,7 +115,7 @@ bitflags!(
const DO_NOT_ENTER = 0x20_00_00;
const BOT_CLIP = 0x40_00_00;
const MOVER = 0x80_00_00;
-
+
// removed before bsping an entity
const ORIGIN = 0x01_00_00_00;
@@ -125,18 +124,18 @@ bitflags!(
/// brush not used for the bsp
const DETAIL = 0x08_00_00_00;
-
+
/// brush not used for the bsp
const CORPSE = 0x04_00_00_00;
/// brushes used for the bsp
const STRUCTURAL = 0x10_00_00_00;
-
+
/// don't consume surface fragments inside
const TRANSLUCENT = 0x20_00_00_00;
const TRIGGER = 0x40_00_00_00;
-
+
/// don't leave bodies or items (death fog, lava)
const NODROP = 0x80_00_00_00;
}
@@ -145,6 +144,6 @@ bitflags!(
pub trait HasTextures {
type TexturesIter<'a>: Iterator<Item = &'a Texture>;
- fn textures_iter<'a>(&'a self) -> Self::TexturesIter<'a>;
- fn get_texture<'a>(&'a self, idx: u32) -> &'a Texture;
+ fn textures_iter(&self) -> Self::TexturesIter<'_>;
+ fn get_texture(&self, idx: u32) -> &Texture;
}
diff --git a/stockton-levels/src/traits/tree.rs b/stockton-levels/src/traits/tree.rs
index c56576a..89be1c1 100644
--- a/stockton-levels/src/traits/tree.rs
+++ b/stockton-levels/src/traits/tree.rs
@@ -17,9 +17,9 @@
//! Parses the BSP tree into a usable format
-use na::Vector3;
-use super::{HasFaces, HasBrushes, HasVisData};
+use super::{HasBrushes, HasFaces, HasVisData};
use crate::coords::CoordSystem;
+use na::Vector3;
/// A node in a BSP tree.
/// Either has two children *or* a leaf entry.
@@ -28,13 +28,13 @@ pub struct BSPNode {
pub plane_idx: u32,
pub min: Vector3<i32>,
pub max: Vector3<i32>,
- pub value: BSPNodeValue
+ pub value: BSPNodeValue,
}
#[derive(Debug, Clone)]
pub enum BSPNodeValue {
- Leaf (BSPLeaf),
- Children (Box<BSPNode>, Box<BSPNode>)
+ Leaf(BSPLeaf),
+ Children(Box<BSPNode>, Box<BSPNode>),
}
/// A leaf in a BSP tree.
@@ -48,5 +48,5 @@ pub struct BSPLeaf {
}
pub trait HasBSPTree<S: CoordSystem>: HasFaces<S> + HasBrushes<S> + HasVisData {
- fn get_bsp_root<'a>(&'a self) -> &'a BSPNode;
-} \ No newline at end of file
+ fn get_bsp_root(&self) -> &BSPNode;
+}
diff --git a/stockton-levels/src/traits/vertices.rs b/stockton-levels/src/traits/vertices.rs
index 7b14c98..ddf315b 100644
--- a/stockton-levels/src/traits/vertices.rs
+++ b/stockton-levels/src/traits/vertices.rs
@@ -15,12 +15,11 @@
// You should have received a copy of the GNU General Public License
// along with stockton-bsp. If not, see <http://www.gnu.org/licenses/>.
-use crate::helpers::{slice_to_f32};
use crate::coords::CoordSystem;
+use crate::helpers::slice_to_f32;
use crate::types::RGBA;
use na::Vector3;
-
/// A vertex, used to describe a face.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vertex {
@@ -54,17 +53,17 @@ pub type MeshVert = u32;
pub trait HasVertices<S: CoordSystem> {
type VerticesIter<'a>: Iterator<Item = &'a Vertex>;
- fn vertices_iter<'a>(&'a self) -> Self::VerticesIter<'a>;
- fn get_vertex<'a>(&'a self, index: u32) -> &'a Vertex;
+ fn vertices_iter(&self) -> Self::VerticesIter<'_>;
+ fn get_vertex(&self, index: u32) -> &Vertex;
}
pub trait HasMeshVerts<S: CoordSystem>: HasVertices<S> {
type MeshVertsIter<'a>: Iterator<Item = &'a MeshVert>;
- fn meshverts_iter<'a>(&'a self) -> Self::MeshVertsIter<'a>;
+ fn meshverts_iter(&self) -> Self::MeshVertsIter<'_>;
fn get_meshvert(&self, index: u32) -> MeshVert;
- fn resolve_meshvert<'a>(&'a self, index: u32, base: u32) -> &'a Vertex {
+ fn resolve_meshvert(&self, index: u32, base: u32) -> &Vertex {
self.get_vertex(self.get_meshvert(index) + base)
}
-} \ No newline at end of file
+}
diff --git a/stockton-levels/src/traits/visdata.rs b/stockton-levels/src/traits/visdata.rs
index 92ba9b8..749000b 100644
--- a/stockton-levels/src/traits/visdata.rs
+++ b/stockton-levels/src/traits/visdata.rs
@@ -1,4 +1,4 @@
-// Copyright (C) Oscar Shrimpton 2019
+// Copyright (C) Oscar Shrimpton 2019
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -18,12 +18,12 @@ use std::iter::Iterator;
pub type ClusterId = u32;
pub trait HasVisData {
- /// The iterator returned from all_visible_from
- type VisibleIterator: Iterator<Item = ClusterId>;
+ /// The iterator returned from all_visible_from
+ type VisibleIterator: Iterator<Item = ClusterId>;
- /// Returns an iterator of all clusters visible from the given Cluster ID
- fn all_visible_from(&self, from: ClusterId) -> Self::VisibleIterator;
+ /// Returns an iterator of all clusters visible from the given Cluster ID
+ fn all_visible_from(&self, from: ClusterId) -> Self::VisibleIterator;
- /// Returns true if `dest` is visible from `from`.
- fn cluster_visible_from(&self, from: ClusterId, dest: ClusterId) -> bool;
-} \ No newline at end of file
+ /// Returns true if `dest` is visible from `from`.
+ fn cluster_visible_from(&self, from: ClusterId, dest: ClusterId) -> bool;
+}