Skip to content

Commit 13a1391

Browse files
committed
Draw fewer fishbones to improve Path gizmo readability and performance
This affects both Path2D and Path3D.
1 parent 0e3a5ed commit 13a1391

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

editor/plugins/path_3d_editor_plugin.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,19 @@ void Path3DGizmo::redraw() {
340340
// Path3D as a ribbon.
341341
ribbon_ptr[i] = p1;
342342

343-
// Fish Bone.
344-
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
345-
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
346-
347-
const int bone_idx = i * 4;
348-
349-
bones_ptr[bone_idx] = p1;
350-
bones_ptr[bone_idx + 1] = p_left;
351-
bones_ptr[bone_idx + 2] = p1;
352-
bones_ptr[bone_idx + 3] = p_right;
343+
if (i % 4 == 0) {
344+
// Draw fish bone every 4 points to reduce visual noise and performance impact
345+
// (compared to drawing it for every point).
346+
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
347+
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
348+
349+
const int bone_idx = i * 4;
350+
351+
bones_ptr[bone_idx] = p1;
352+
bones_ptr[bone_idx + 1] = p_left;
353+
bones_ptr[bone_idx + 2] = p1;
354+
bones_ptr[bone_idx + 3] = p_right;
355+
}
353356
}
354357

355358
add_collision_segments(_collision_segments);

scene/2d/path_2d.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ void Path2D::_notification(int p_what) {
138138
draw_polyline(v2p, get_tree()->get_debug_paths_color(), line_width, false);
139139
}
140140

141-
// Draw fish bones
141+
// Draw fish bone every 4 points to reduce visual noise and performance impact
142+
// (compared to drawing it for every point).
142143
{
143144
PackedVector2Array v2p;
144145
v2p.resize(3);
145146
Vector2 *w = v2p.ptrw();
146147

147-
for (int i = 0; i < sample_count; i++) {
148+
for (int i = 0; i < sample_count; i += 4) {
148149
const Vector2 p = r[i].get_origin();
149150
const Vector2 side = r[i].columns[1];
150151
const Vector2 forward = r[i].columns[0];

scene/3d/path_3d.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,19 @@ void Path3D::_update_debug_mesh() {
131131
// Path3D as a ribbon.
132132
ribbon_ptr[i] = p1;
133133

134-
// Fish Bone.
135-
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
136-
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
137-
138-
const int bone_idx = i * 4;
139-
140-
bones_ptr[bone_idx] = p1;
141-
bones_ptr[bone_idx + 1] = p_left;
142-
bones_ptr[bone_idx + 2] = p1;
143-
bones_ptr[bone_idx + 3] = p_right;
134+
if (i % 4 == 0) {
135+
// Draw fish bone every 4 points to reduce visual noise and performance impact
136+
// (compared to drawing it for every point).
137+
const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
138+
const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
139+
140+
const int bone_idx = i * 4;
141+
142+
bones_ptr[bone_idx] = p1;
143+
bones_ptr[bone_idx + 1] = p_left;
144+
bones_ptr[bone_idx + 2] = p1;
145+
bones_ptr[bone_idx + 3] = p_right;
146+
}
144147
}
145148

146149
Array ribbon_array;

0 commit comments

Comments
 (0)