-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b17b600
commit 12839e7
Showing
4 changed files
with
28 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,15 @@ | ||
use crate::{VerletPoint, VerletStick}; | ||
use bevy::log; | ||
use bevy::prelude::*; | ||
|
||
macro_rules! get_point_debug { | ||
($res:expr) => { | ||
match $res { | ||
Ok(p) => p, | ||
Err(e) => { | ||
log::warn!("Could not find point entity to draw debug stick: {}", e); | ||
return None; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
fn draw_stick( | ||
stick: &VerletStick, | ||
points_query: &Query<&GlobalTransform, With<VerletPoint>>, | ||
) -> Option<(Vec3, Vec3)> { | ||
let transform_a = get_point_debug!(points_query.get(stick.point_a_entity)); | ||
let transform_b = get_point_debug!(points_query.get(stick.point_b_entity)); | ||
Some((transform_a.translation(), transform_b.translation())) | ||
} | ||
|
||
#[allow(clippy::needless_pass_by_value)] | ||
pub fn debug_draw_sticks( | ||
mut gizmos: Gizmos, | ||
sticks_query: Query<&VerletStick>, | ||
points_query: Query<&GlobalTransform, With<VerletPoint>>, | ||
) { | ||
for stick in sticks_query.iter() { | ||
if let Some((a, b)) = draw_stick(stick, &points_query) { | ||
gizmos.line(a, b, Color::WHITE); | ||
if let Ok([a, b]) = points_query.get_many(stick.entities()) { | ||
gizmos.line(a.translation(), b.translation(), Color::WHITE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters