Skip to content

Commit 466f442

Browse files
committed
.
1 parent 825c429 commit 466f442

File tree

3 files changed

+137
-83
lines changed

3 files changed

+137
-83
lines changed

t1/src/debug_draw_b.rs

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use egui::Vec2;
12
use glam::{Vec3, Vec4};
23
use std::f32::consts::PI;
3-
use egui::Vec2;
44

55
// Input mesh data structure
66
pub struct InputMesh {
@@ -24,7 +24,7 @@ pub fn du_debug_draw_tri_mesh_slope(
2424
dd: &mut impl DebugDraw,
2525
mesh: &InputMesh,
2626
walkable_slope_angle: f32,
27-
tex_scale: f32
27+
tex_scale: f32,
2828
) {
2929
if mesh.verts.is_empty() || mesh.tris.is_empty() || mesh.normals.is_empty() {
3030
return;
@@ -34,26 +34,21 @@ pub fn du_debug_draw_tri_mesh_slope(
3434
let walkable_thr = (walkable_slope_angle / 180.0 * PI).cos();
3535

3636
dd.texture(true);
37-
37+
3838
dd.begin(DU_DRAW_TRIS, 1.0);
39-
39+
4040
let unwalkable = Vec4::new(0.75, 0.5, 0.0, 1.0); // Similar to duRGBA(192,128,0,255)
41-
41+
4242
// Process triangles
4343
for i in (0..mesh.tris.len()).step_by(3) {
4444
let norm = &mesh.normals[i];
45-
45+
4646
// Calculate color based on slope
4747
let a = ((2.0 + norm.x + norm.y) / 4.0 * 220.0) as u8;
48-
let base_col = Vec4::new(
49-
a as f32 / 255.0,
50-
a as f32 / 255.0,
51-
a as f32 / 255.0,
52-
1.0
53-
);
54-
48+
let base_col = Vec4::new(a as f32 / 255.0, a as f32 / 255.0, a as f32 / 255.0, 1.0);
49+
5550
let color = if norm.y < walkable_thr {
56-
lerp_col(base_col, unwalkable, 64.0/255.0)
51+
lerp_col(base_col, unwalkable, 64.0 / 255.0)
5752
} else {
5853
base_col
5954
};
@@ -66,14 +61,14 @@ pub fn du_debug_draw_tri_mesh_slope(
6661
// Calculate texture coordinates
6762
let mut ax = 0;
6863
let mut ay = 0;
69-
64+
7065
if norm.y.abs() > norm[ax].abs() {
7166
ax = 1;
7267
}
7368
if norm.z.abs() > norm[ax].abs() {
7469
ax = 2;
7570
}
76-
71+
7772
ax = (1 << ax) & 3; // +1 mod 3
7873
ay = (1 << ax) & 3; // +1 mod 3
7974

@@ -85,7 +80,7 @@ pub fn du_debug_draw_tri_mesh_slope(
8580
dd.vertex_uv(*vb, color, uvb);
8681
dd.vertex_uv(*vc, color, uvc);
8782
}
88-
83+
8984
dd.end();
9085
dd.texture(false);
9186
}

t1/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod debug_draw_b;
2-
mod viewer;
32
mod obj_loader;
3+
mod viewer;
44

55
fn main() -> Result<(), eframe::Error> {
66
viewer::run()

0 commit comments

Comments
 (0)