From 66e9d1a803f5f7b96014d0c36b5bc98338bc4a54 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 12 Aug 2023 22:06:03 +0300 Subject: [PATCH] ability to draw arrows in scene debug drawing context - #462 --- src/scene/debug.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/scene/debug.rs b/src/scene/debug.rs index e0e35beb3..35185e2b7 100644 --- a/src/scene/debug.rs +++ b/src/scene/debug.rs @@ -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. @@ -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, + ) { + 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);