Skip to content

Commit 37a3ab9

Browse files
author
Jakub Hlusička
committed
Code cleanup
1 parent 31d453b commit 37a3ab9

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ crate-type = ['cdylib']
1313
wasm-bindgen = "0.2.55"
1414
lazy_static = "1.4.0"
1515
ammolite-math = { path = "../ammolite/ammolite-math" }
16-
# generic-array = "0.13.2"
17-
# typenum = "1.10"
1816
serde = { version = "1.0", features = ["derive"] }
1917
json5 = "0.2.5"
2018
mlib = { path = "../mlib" }

src/lib.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
use std::time::Duration;
2-
use std::io::Read;
32
use std::collections::VecDeque;
43
use ammolite_math::*;
54
use wasm_bindgen::prelude::*;
6-
use lazy_static::lazy_static;
75
use mlib::*;
86

7+
#[allow(unused)]
98
macro_rules! print {
109
($mapp:ident, $($tt:tt)*) => {
1110
let formatted = format!($($tt)*);
1211
$mapp.io.out.extend(formatted.as_bytes());
1312
}
1413
}
1514

15+
#[allow(unused)]
1616
macro_rules! println {
1717
($mapp:ident, $($tt:tt)*) => {
1818
print!($mapp, $($tt)*);
1919
$mapp.io.out.push('\n' as u8)
2020
}
2121
}
2222

23+
#[allow(unused)]
2324
macro_rules! eprint {
2425
($mapp:ident, $($tt:tt)*) => {
2526
let formatted = format!($($tt)*);
2627
$mapp.io.err.extend(formatted.as_bytes());
2728
}
2829
}
2930

31+
#[allow(unused)]
3032
macro_rules! eprintln {
3133
($mapp:ident, $($tt:tt)*) => {
3234
eprint!($mapp, $($tt)*);
@@ -35,6 +37,7 @@ macro_rules! eprintln {
3537
}
3638

3739
// Implementation from https://doc.rust-lang.org/std/macro.dbg.html
40+
#[allow(unused)]
3841
macro_rules! dbg {
3942
($mapp:ident, ) => {
4043
eprintln!($mapp, "[{}:{}]", file!(), line!());
@@ -61,16 +64,17 @@ const MODEL_BUTTON_NEXT_BYTES: &'static [u8] = include_bytes!("/home/limeth/Docu
6164
// TODO: Use a procedural macro to output include_bytes! macros for every model
6265
// in the resources directory (if a feature is used/release build; otherwise it
6366
// would slow down linting)
64-
const MODELS_MAIN_LEN: usize = 5;
67+
const MODELS_MAIN_LEN: usize = 1;
6568
const MODELS_MAIN_BYTES_SCALE: [(&'static [u8], f32); MODELS_MAIN_LEN] = [
66-
(include_bytes!("../../ammolite/resources/DamagedHelmet/glTF-Binary/DamagedHelmet.glb"), 1.0),
67-
(include_bytes!("../../ammolite/resources/Corset/glTF-Binary/Corset.glb"), 40.0),
68-
(include_bytes!("../../ammolite/resources/AntiqueCamera/glTF-Binary/AntiqueCamera.glb"), 0.1),
69+
// (include_bytes!("../../ammolite/resources/DamagedHelmet/glTF-Binary/DamagedHelmet.glb"), 1.0),
70+
// (include_bytes!("../../ammolite/resources/Corset/glTF-Binary/Corset.glb"), 40.0),
71+
// (include_bytes!("../../ammolite/resources/AntiqueCamera/glTF-Binary/AntiqueCamera.glb"), 0.1),
6972
(include_bytes!("../../ammolite/resources/WaterBottle/glTF-Binary/WaterBottle.glb"), 5.0),
70-
(include_bytes!("/home/limeth/Documents/School/mvr/team07/mvr_3D_models/hlusijak/laser/zaba.glb"), 0.01),
73+
// (include_bytes!("/home/limeth/Documents/School/mvr/team07/mvr_3D_models/hlusijak/laser/zaba.glb"), 0.01),
7174
];
7275
const MODEL_MARKER_BYTES: &'static [u8] = include_bytes!("../../ammolite/resources/sphere_1m_radius.glb");
7376
const SELECTION_DELAY: f32 = 1.0;
77+
const ANIMATION_SPEED: f32 = 0.0;
7478
const ENTITY_COUNT: usize = 20;
7579

7680
fn construct_model_matrix(scale: f32, translation: &Vec3, rotation: &Vec3) -> Mat4 {
@@ -214,8 +218,6 @@ impl Mapp for ExampleMapp {
214218
let secs_elapsed = duration_to_seconds(elapsed);
215219
// dbg!(self, elapsed);
216220
// dbg!(self, secs_elapsed);
217-
let anim_speed = 0.2;
218-
219221
for (index, entity) in self.entities_main.clone().iter().enumerate() {
220222
if entity.is_none() {
221223
return;
@@ -224,7 +226,7 @@ impl Mapp for ExampleMapp {
224226
let transform = construct_model_matrix(
225227
MODELS_MAIN_BYTES_SCALE[self.current_main_model_index].1,
226228
&[0.0, 0.0, 2.0 + 1.0 * index as f32].into(),
227-
&[(secs_elapsed * anim_speed).sin() * 1.0, std::f32::consts::PI + (secs_elapsed * anim_speed).cos() * 3.0 / 2.0, 0.0].into(),
229+
&[(secs_elapsed * ANIMATION_SPEED).sin() * 1.0, std::f32::consts::PI + (secs_elapsed * ANIMATION_SPEED).cos() * 3.0 / 2.0, 0.0].into(),
228230
);
229231

230232
self.cmd(CommandKind::EntityTransformSet {
@@ -285,15 +287,15 @@ impl Mapp for ExampleMapp {
285287
(model_selector, transform)
286288
};
287289
self.cmd(CommandKind::EntityParentSet {
288-
entity: entity,
290+
entity,
289291
parent_entity: self.root_entity,
290292
});
291293
self.cmd(CommandKind::EntityModelSet {
292-
entity: entity,
294+
entity,
293295
model: model_selector,
294296
});
295297
self.cmd(CommandKind::EntityTransformSet {
296-
entity: entity,
298+
entity,
297299
transform: Some(transform),
298300
});
299301
},
@@ -339,7 +341,7 @@ impl Mapp for ExampleMapp {
339341
});
340342
self.cmd(CommandKind::RayTrace {
341343
origin: position,
342-
direction: direction,
344+
direction,
343345
});
344346
}
345347
},
@@ -362,7 +364,7 @@ impl Mapp for ExampleMapp {
362364
});
363365

364366
self.ray_tracing_task = Some(RayTracingTask {
365-
direction: direction,
367+
direction,
366368
total_distance,
367369
});
368370
} else {

0 commit comments

Comments
 (0)