From 4f16559e4db546fa5ef4c4b67b36d3e0ce5fd93d Mon Sep 17 00:00:00 2001 From: b-guild Date: Sun, 30 Jun 2024 11:58:25 -0700 Subject: [PATCH] Terrain brush gizmo size fix and comment tweaks. --- editor/src/interaction/terrain.rs | 4 +++- .../scene/terrain/brushstroke/brushraster.rs | 18 +++++++++++++----- .../src/scene/terrain/brushstroke/mod.rs | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/editor/src/interaction/terrain.rs b/editor/src/interaction/terrain.rs index 5ff77a45e..01ff9ef79 100644 --- a/editor/src/interaction/terrain.rs +++ b/editor/src/interaction/terrain.rs @@ -369,7 +369,9 @@ impl InteractionMode for TerrainInteractionMode { } let scale = match self.brush.shape { - BrushShape::Circle { radius } => Vector3::new(radius, radius, 1.0), + BrushShape::Circle { radius } => { + Vector3::new(radius * 2.0, radius * 2.0, 1.0) + } BrushShape::Rectangle { width, length } => { Vector3::new(width, length, 1.0) } diff --git a/fyrox-impl/src/scene/terrain/brushstroke/brushraster.rs b/fyrox-impl/src/scene/terrain/brushstroke/brushraster.rs index 5e5778da1..d370479e4 100644 --- a/fyrox-impl/src/scene/terrain/brushstroke/brushraster.rs +++ b/fyrox-impl/src/scene/terrain/brushstroke/brushraster.rs @@ -12,6 +12,7 @@ use crate::core::{ math::{OptionRect, Rect}, }; +/// Adjust the strength of a brush pixel based on the hardness of the brush. fn apply_hardness(hardness: f32, strength: f32) -> f32 { if strength == 0.0 { return 0.0; @@ -33,6 +34,9 @@ pub trait BrushRaster { /// An AABB that contains all the pixels of the brush, with (0.0, 0.0) being /// at the center of the brush. fn bounds(&self) -> Rect; + /// An AABB that contains all the pixels of the brush after it has been transformed + /// and translated. First the brush is multiplied by `transform` and then it is + /// translated to `center`, and then an AABB it calculated for the resulting brush. fn transformed_bounds(&self, center: Vector2, transform: &Matrix2) -> Rect { let mut bounds = OptionRect::::default(); let rect = self.bounds(); @@ -148,6 +152,9 @@ impl Iterator for RectIter { } } +/// An iterator over the pixels of a [BrushRaster] object. +/// For each pixel, it produces a [BrushPixel]. +/// The pixels produced can include pixels with zero strength. #[derive(Debug, Clone)] pub struct StampPixels { brush_raster: R, @@ -161,11 +168,11 @@ impl StampPixels where R: BrushRaster, { + /// An AABB containing all the pixels that this iterator produces. pub fn bounds(&self) -> Rect { self.bounds_iter.bounds() } - /// Construct a new pixel iterator for a round brush at the given position, radius, - /// and 2x2 transform matrix. + /// Construct a new pixel iterator for a stamp at the given location. pub fn new( brush_raster: R, center: Vector2, @@ -205,7 +212,9 @@ where } } -/// An iterator of the pixels of a round brush. +/// An iterator of the pixels that are painted when a brush +/// is smeared from a start point to an end point. +/// It works just like [StampPixels] but across a line segment instead of at a single point. #[derive(Debug, Clone)] pub struct SmearPixels { brush_raster: R, @@ -221,8 +230,7 @@ impl SmearPixels { pub fn bounds(&self) -> Rect { self.bounds_iter.bounds() } - /// Construct a new pixel iterator for a brush at the given position, radius, - /// and 2x2 transform matrix. + /// Construct a new pixel iterator for a smear with the given start and end points. pub fn new( brush_raster: R, start: Vector2, diff --git a/fyrox-impl/src/scene/terrain/brushstroke/mod.rs b/fyrox-impl/src/scene/terrain/brushstroke/mod.rs index c995428a4..00d7d9d58 100644 --- a/fyrox-impl/src/scene/terrain/brushstroke/mod.rs +++ b/fyrox-impl/src/scene/terrain/brushstroke/mod.rs @@ -34,7 +34,7 @@ use fyrox_core::uuid_provider; use std::collections::VecDeque; use std::sync::mpsc::{Receiver, SendError, Sender}; -mod brushraster; +pub mod brushraster; use brushraster::*; mod strokechunks; use strokechunks::*;