1
+ use egui:: Vec2 ;
1
2
use glam:: { Vec3 , Vec4 } ;
2
3
use std:: f32:: consts:: PI ;
3
- use egui:: Vec2 ;
4
4
5
5
// Input mesh data structure
6
6
pub struct InputMesh {
@@ -24,7 +24,7 @@ pub fn du_debug_draw_tri_mesh_slope(
24
24
dd : & mut impl DebugDraw ,
25
25
mesh : & InputMesh ,
26
26
walkable_slope_angle : f32 ,
27
- tex_scale : f32
27
+ tex_scale : f32 ,
28
28
) {
29
29
if mesh. verts . is_empty ( ) || mesh. tris . is_empty ( ) || mesh. normals . is_empty ( ) {
30
30
return ;
@@ -34,26 +34,21 @@ pub fn du_debug_draw_tri_mesh_slope(
34
34
let walkable_thr = ( walkable_slope_angle / 180.0 * PI ) . cos ( ) ;
35
35
36
36
dd. texture ( true ) ;
37
-
37
+
38
38
dd. begin ( DU_DRAW_TRIS , 1.0 ) ;
39
-
39
+
40
40
let unwalkable = Vec4 :: new ( 0.75 , 0.5 , 0.0 , 1.0 ) ; // Similar to duRGBA(192,128,0,255)
41
-
41
+
42
42
// Process triangles
43
43
for i in ( 0 ..mesh. tris . len ( ) ) . step_by ( 3 ) {
44
44
let norm = & mesh. normals [ i] ;
45
-
45
+
46
46
// Calculate color based on slope
47
47
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
+
55
50
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 )
57
52
} else {
58
53
base_col
59
54
} ;
@@ -66,14 +61,14 @@ pub fn du_debug_draw_tri_mesh_slope(
66
61
// Calculate texture coordinates
67
62
let mut ax = 0 ;
68
63
let mut ay = 0 ;
69
-
64
+
70
65
if norm. y . abs ( ) > norm[ ax] . abs ( ) {
71
66
ax = 1 ;
72
67
}
73
68
if norm. z . abs ( ) > norm[ ax] . abs ( ) {
74
69
ax = 2 ;
75
70
}
76
-
71
+
77
72
ax = ( 1 << ax) & 3 ; // +1 mod 3
78
73
ay = ( 1 << ax) & 3 ; // +1 mod 3
79
74
@@ -85,7 +80,7 @@ pub fn du_debug_draw_tri_mesh_slope(
85
80
dd. vertex_uv ( * vb, color, uvb) ;
86
81
dd. vertex_uv ( * vc, color, uvc) ;
87
82
}
88
-
83
+
89
84
dd. end ( ) ;
90
85
dd. texture ( false ) ;
91
86
}
0 commit comments