summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/src/camera.rs13
-rw-r--r--engine/src/object.rs6
-rw-r--r--engine/src/opengl/currently_bound.rs4
-rw-r--r--engine/src/transform.rs6
-rw-r--r--engine/src/vector.rs6
-rw-r--r--engine/src/vertex.rs5
-rw-r--r--glfw/src/window.rs5
-rw-r--r--rustfmt.toml2
-rw-r--r--src/main.rs77
9 files changed, 23 insertions, 101 deletions
diff --git a/engine/src/camera.rs b/engine/src/camera.rs
index 9ab95e7..fab92f5 100644
--- a/engine/src/camera.rs
+++ b/engine/src/camera.rs
@@ -83,16 +83,9 @@ impl Camera
pub(crate) fn new() -> Self
{
- let position = Vec3 {
- x: 0.0,
- y: 0.0,
- z: 3.0,
- };
-
- Self {
- position,
- target: Vec3::default(),
- }
+ let position = Vec3 { x: 0.0, y: 0.0, z: 3.0 };
+
+ Self { position, target: Vec3::default() }
}
pub(crate) fn as_matrix(&self) -> Matrix<f32, 4, 4>
diff --git a/engine/src/object.rs b/engine/src/object.rs
index 9952c5f..dffd240 100644
--- a/engine/src/object.rs
+++ b/engine/src/object.rs
@@ -62,11 +62,7 @@ impl Object
let transform = Transform::new();
- Ok(Self {
- id,
- renderable,
- transform,
- })
+ Ok(Self { id, renderable, transform })
}
/// Returns the object ID.
diff --git a/engine/src/opengl/currently_bound.rs b/engine/src/opengl/currently_bound.rs
index eefa239..be01841 100644
--- a/engine/src/opengl/currently_bound.rs
+++ b/engine/src/opengl/currently_bound.rs
@@ -15,8 +15,6 @@ impl<'token, Object> CurrentlyBound<'token, Object>
#[must_use]
pub unsafe fn new() -> Self
{
- Self {
- _token: PhantomData,
- }
+ Self { _token: PhantomData }
}
}
diff --git a/engine/src/transform.rs b/engine/src/transform.rs
index c216fdd..b01e3c1 100644
--- a/engine/src/transform.rs
+++ b/engine/src/transform.rs
@@ -14,11 +14,7 @@ impl Transform
{
Self {
translation: Vec3::default(),
- scaling: Vec3 {
- x: 1.0,
- y: 1.0,
- z: 1.0,
- },
+ scaling: Vec3 { x: 1.0, y: 1.0, z: 1.0 },
}
}
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index e8d51d2..00b2ea5 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -23,11 +23,7 @@ pub struct Vec3<Value>
impl Vec3<f32>
{
- pub const UP: Self = Self {
- x: 0.0,
- y: 1.0,
- z: 0.0,
- };
+ pub const UP: Self = Self { x: 0.0, y: 1.0, z: 0.0 };
/// Returns the length of the vector.
#[must_use]
diff --git a/engine/src/vertex.rs b/engine/src/vertex.rs
index e03eacb..592353a 100644
--- a/engine/src/vertex.rs
+++ b/engine/src/vertex.rs
@@ -23,10 +23,7 @@ impl Builder
#[must_use]
pub fn new() -> Self
{
- Self {
- pos: None,
- color: None,
- }
+ Self { pos: None, color: None }
}
#[must_use]
diff --git a/glfw/src/window.rs b/glfw/src/window.rs
index 1f3834e..b0c07ff 100644
--- a/glfw/src/window.rs
+++ b/glfw/src/window.rs
@@ -221,10 +221,7 @@ impl Builder
get_glfw_error()?;
- Ok(Window {
- _init: init,
- handle,
- })
+ Ok(Window { _init: init, handle })
}
}
diff --git a/rustfmt.toml b/rustfmt.toml
index 4d1e29f..df78ba9 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -8,4 +8,4 @@ imports_layout = "HorizontalVertical"
imports_granularity = "Module"
newline_style = "Unix"
reorder_impl_items = true
-
+struct_lit_width = 36
diff --git a/src/main.rs b/src/main.rs
index ad59b38..eb89fef 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,16 +8,9 @@ use engine::{Engine, Key, WindowSize};
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
-const WINDOW_SIZE: WindowSize = WindowSize {
- width: 500,
- height: 600,
-};
+const WINDOW_SIZE: WindowSize = WindowSize { width: 500, height: 600 };
-const BLUE: Color<f32> = Color {
- red: 0.0,
- blue: 1.0,
- green: 0.0,
-};
+const BLUE: Color<f32> = Color { red: 0.0, blue: 1.0, green: 0.0 };
fn main() -> Result<(), Box<dyn Error>>
{
@@ -33,53 +26,25 @@ fn main() -> Result<(), Box<dyn Error>>
ObjectId::new(1),
&[
VertexBuilder::new()
- .pos(Vec3 {
- x: -0.5,
- y: -0.5,
- z: 0.0,
- })
- .color(Color {
- red: 1.0,
- green: 0.0,
- blue: 0.0,
- })
+ .pos(Vec3 { x: -0.5, y: -0.5, z: 0.0 })
+ .color(Color { red: 1.0, green: 0.0, blue: 0.0 })
.build()
.unwrap(),
VertexBuilder::new()
- .pos(Vec3 {
- x: 0.5,
- y: -0.5,
- z: 0.0,
- })
- .color(Color {
- red: 0.0,
- green: 1.0,
- blue: 0.0,
- })
+ .pos(Vec3 { x: 0.5, y: -0.5, z: 0.0 })
+ .color(Color { red: 0.0, green: 1.0, blue: 0.0 })
.build()
.unwrap(),
VertexBuilder::new()
- .pos(Vec3 {
- x: 0.0,
- y: 0.5,
- z: 0.0,
- })
- .color(Color {
- red: 0.0,
- green: 0.0,
- blue: 1.0,
- })
+ .pos(Vec3 { x: 0.0, y: 0.5, z: 0.0 })
+ .color(Color { red: 0.0, green: 0.0, blue: 1.0 })
.build()
.unwrap(),
],
None,
)?;
- triangle.translate(Vec3 {
- x: 0.0,
- y: 0.4,
- z: 0.0,
- });
+ triangle.translate(Vec3 { x: 0.0, y: 0.4, z: 0.0 });
engine.add_object(triangle);
@@ -87,38 +52,22 @@ fn main() -> Result<(), Box<dyn Error>>
ObjectId::new(2),
&[
VertexBuilder::new()
- .pos(Vec3 {
- x: 0.5,
- y: 0.5,
- z: 0.0,
- })
+ .pos(Vec3 { x: 0.5, y: 0.5, z: 0.0 })
.color(BLUE)
.build()
.unwrap(),
VertexBuilder::new()
- .pos(Vec3 {
- x: 0.5,
- y: -0.5,
- z: 0.0,
- })
+ .pos(Vec3 { x: 0.5, y: -0.5, z: 0.0 })
.color(BLUE)
.build()
.unwrap(),
VertexBuilder::new()
- .pos(Vec3 {
- x: -0.5,
- y: -0.5,
- z: 0.0,
- })
+ .pos(Vec3 { x: -0.5, y: -0.5, z: 0.0 })
.color(BLUE)
.build()
.unwrap(),
VertexBuilder::new()
- .pos(Vec3 {
- x: -0.5,
- y: 0.5,
- z: 0.0,
- })
+ .pos(Vec3 { x: -0.5, y: 0.5, z: 0.0 })
.color(BLUE)
.build()
.unwrap(),