From 1677ca2549f2582ceb5081e49a56766908f85ac9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 19 Feb 2022 11:47:52 +0100 Subject: [PATCH] Remove workaround --- src/graphics/vertices.rs | 8 +------- src/main.rs | 4 ++-- src/mesh.rs | 35 ----------------------------------- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/graphics/vertices.rs b/src/graphics/vertices.rs index 9ff42e22a..316b8d37d 100644 --- a/src/graphics/vertices.rs +++ b/src/graphics/vertices.rs @@ -4,7 +4,7 @@ use nalgebra::{vector, Point}; use crate::{ debug::DebugInfo, math::Triangle, - mesh::{HashVector, Index, MeshMaker}, + mesh::{Index, MeshMaker}, }; #[derive(Debug)] @@ -57,12 +57,6 @@ impl From<&Vec> for Vertices { let normal = (b - a).cross(&(c - a)).normalize(); - let a = HashVector::from(&a.to_na()); - let b = HashVector::from(&b.to_na()); - let c = HashVector::from(&c.to_na()); - - let normal = HashVector::from(&normal.to_na()); - mesh.push((a, normal)); mesh.push((b, normal)); mesh.push((c, normal)); diff --git a/src/main.rs b/src/main.rs index 654dae2d3..9433d0de4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ use crate::{ debug::DebugInfo, graphics::{DrawConfig, Renderer}, kernel::Shape as _, - mesh::{HashVector, MeshMaker}, + mesh::MeshMaker, model::Model, window::Window, }; @@ -97,7 +97,7 @@ fn main() -> anyhow::Result<()> { for triangle in triangles { for vertex in triangle.vertices() { - mesh_maker.push(HashVector::from(&vertex.to_na())); + mesh_maker.push(vertex); } } diff --git a/src/mesh.rs b/src/mesh.rs index 2e22bfc61..85a7e0b4d 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -1,8 +1,5 @@ use std::{collections::HashMap, hash::Hash}; -use decorum::R64; -use nalgebra::{Point, SVector}; - /// API for creating a mesh pub struct MeshMaker { vertices: Vec, @@ -47,37 +44,5 @@ where } } -/// A point/vector type that can be used as a [`HashMap`] key -#[derive(Clone, Copy, Eq, Hash, PartialEq)] -pub struct HashVector(pub [R64; 3]); - -impl From<&Point> for HashVector { - fn from(point: &Point) -> Self { - Self([R64::from(point.x), R64::from(point.y), R64::from(point.z)]) - } -} - -impl From<&SVector> for HashVector { - fn from(vector: &SVector) -> Self { - Self([ - R64::from(vector.x), - R64::from(vector.y), - R64::from(vector.z), - ]) - } -} - -impl From for [f32; 3] { - fn from(hash_vector: HashVector) -> Self { - hash_vector.0.map(|coord| coord.into_inner() as f32) - } -} - -impl From for [f64; 3] { - fn from(hash_vector: HashVector) -> Self { - hash_vector.0.map(|coord| coord.into_inner()) - } -} - /// An index that refers to a vertex in a mesh pub type Index = u32;