Skip to content

Commit

Permalink
ability to draw arrows in scene debug drawing context
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Aug 12, 2023
1 parent 85ad81d commit 66e9d1a
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/scene/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
//! For more info see [`SceneDrawingContext`]
use crate::core::{
algebra::{Matrix4, Point3, Vector2, Vector3},
algebra::{Matrix4, Point3, UnitQuaternion, Vector2, Vector3},
color::{Color, Hsl},
math::{aabb::AxisAlignedBoundingBox, frustum::Frustum, Matrix4Ext},
};
use fyrox_core::algebra::UnitQuaternion;
use std::ops::Range;

/// Colored line between two points.
Expand Down Expand Up @@ -1039,6 +1038,31 @@ impl SceneDrawingContext {
}
}

/// Draws an Y+ oriented arrow with the given parameters.
pub fn draw_arrow(
&mut self,
sides: usize,
color: Color,
length: f32,
radius: f32,
transform: Matrix4<f32>,
) {
self.draw_cylinder(sides, radius, length, true, transform, color);

let head_radius = radius * 2.0;
let head_height = radius * 4.0;

self.draw_cone(
sides,
head_radius,
head_height,
transform
* Matrix4::new_translation(&Vector3::new(0.0, (length + head_height) * 0.5, 0.0)),
color,
true,
);
}

/// Adds single line into internal buffer.
pub fn add_line(&mut self, line: Line) {
self.lines.push(line);
Expand Down

0 comments on commit 66e9d1a

Please sign in to comment.