forked from Brickworks/yahs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
019fb96
commit 2faba0e
Showing
12 changed files
with
215 additions
and
136 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use bevy::{color::palettes::basic::*, prelude::*}; | ||
|
||
use crate::simulator::{forces::Force, SimState}; | ||
|
||
const ARROW_SCALE: f32 = 0.1; | ||
|
||
pub struct ForceArrowsPlugin; | ||
|
||
impl Plugin for ForceArrowsPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(PostUpdate, force_arrows); | ||
} | ||
} | ||
|
||
fn force_arrows(query: Query<&dyn Force>, mut gizmos: Gizmos) { | ||
for forces in query.iter() { | ||
for force in forces.iter() { | ||
let start = force.point_of_application(); | ||
let end = start + force.force() * ARROW_SCALE; | ||
let color = force.color().unwrap_or(RED.into()); | ||
gizmos.arrow(start, end, color).with_tip_length(0.1); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.