From 8488a75bd01f5383c4f24c3080bda312ca543b11 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 22 Sep 2023 09:30:27 +0100 Subject: [PATCH] Add basic box brush generator --- editor/src/main.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/editor/src/main.rs b/editor/src/main.rs index 29287b8..aa298cb 100644 --- a/editor/src/main.rs +++ b/editor/src/main.rs @@ -1,11 +1,11 @@ use csg::{ - brush::{self, Brush, BrushPlane, MaterialId, TextureProjection}, - glam::{self}, + brush::{Brush, BrushPlane, MaterialId, TextureProjection}, + glam::{self, Vec3}, plane::Plane, }; -fn main() { - let points = vec![ +fn generate_box_brush(position: Vec3, extent: Vec3) -> Brush { + let normals = vec![ glam::vec3(1.0, 0.0, 0.0), glam::vec3(-1.0, 0.0, 0.0), glam::vec3(0.0, 1.0, 0.0), @@ -15,9 +15,11 @@ fn main() { ]; let mut brush_planes = vec![]; - for point in &points { + for normal in &normals { + let point = position + *normal * extent; + brush_planes.push(BrushPlane { - plane: Plane::from_point_normal(*point, *point), + plane: Plane::from_point_normal(point, *normal), material: MaterialId("Epic".to_string()), tex_projection: TextureProjection::default(), }); @@ -25,9 +27,13 @@ fn main() { println!("Plane: {:?}", brush_planes.last().unwrap().plane); } - let brush = Brush { + Brush { planes: brush_planes, - }; + } +} + +fn main() { + let brush = generate_box_brush(Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 2.0, 1.0)); let vs = brush.get_vertices(); println!("Vertices: {vs:?}");