Skip to content

Commit

Permalink
visualize directional lights as arrows in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Aug 12, 2023
1 parent 9fa033f commit 2ce82e0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/scene/light/directional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use crate::{
core::{
algebra::{UnitQuaternion, Vector3},
color::Color,
math::aabb::AxisAlignedBoundingBox,
pool::Handle,
reflect::prelude::*,
Expand All @@ -18,6 +20,7 @@ use crate::{
},
scene::{
base::Base,
debug::SceneDrawingContext,
graph::Graph,
light::{BaseLight, BaseLightBuilder},
node::{Node, NodeTrait},
Expand Down Expand Up @@ -161,6 +164,18 @@ impl NodeTrait for DirectionalLight {
fn id(&self) -> Uuid {
Self::type_uuid()
}

fn debug_draw(&self, ctx: &mut SceneDrawingContext) {
ctx.draw_arrow(
16,
Color::GREEN,
1.0,
0.2,
self.global_transform()
* UnitQuaternion::from_axis_angle(&Vector3::x_axis(), 180.0f32.to_radians())
.to_homogeneous(),
);
}
}

/// Allows you to build directional light in declarative manner.
Expand Down

0 comments on commit 2ce82e0

Please sign in to comment.