Skip to content

Commit

Permalink
Minor wording change
Browse files Browse the repository at this point in the history
  • Loading branch information
urholaukkarinen committed Jan 30, 2024
1 parent f9f6066 commit b05bcd9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/subgizmo/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub(crate) fn draw_plane<T: SubGizmoState>(subgizmo: &SubGizmoConfig<T>, ui: &Ui
);

let scale = plane_size(subgizmo) * 0.5;
let a = plane_binormal(subgizmo.direction) * scale;
let a = plane_bitangent(subgizmo.direction) * scale;
let b = plane_tangent(subgizmo.direction) * scale;
let origin = plane_local_origin(subgizmo);

Expand Down Expand Up @@ -222,7 +222,7 @@ pub(crate) fn draw_circle<T: SubGizmoState>(subgizmo: &SubGizmoConfig<T>, ui: &U
painter.circle(radius, stroke);
}

pub(crate) fn plane_binormal(direction: GizmoDirection) -> DVec3 {
pub(crate) fn plane_bitangent(direction: GizmoDirection) -> DVec3 {
match direction {
GizmoDirection::X => DVec3::Y,
GizmoDirection::Y => DVec3::Z,
Expand All @@ -249,7 +249,7 @@ pub(crate) fn plane_size<T: SubGizmoState>(subgizmo: &SubGizmoConfig<T>) -> f64
pub(crate) fn plane_local_origin<T: SubGizmoState>(subgizmo: &SubGizmoConfig<T>) -> DVec3 {
let offset = subgizmo.config.scale_factor * subgizmo.config.visuals.gizmo_size * 0.5;

let a = plane_binormal(subgizmo.direction);
let a = plane_bitangent(subgizmo.direction);
let b = plane_tangent(subgizmo.direction);
(a + b) * offset as f64
}
Expand Down
4 changes: 2 additions & 2 deletions src/subgizmo/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::math::{round_to_interval, world_to_screen};

use crate::subgizmo::common::{
draw_arrow, draw_circle, draw_plane, inner_circle_radius, outer_circle_radius, pick_arrow,
pick_circle, pick_plane, plane_binormal, plane_tangent,
pick_circle, pick_plane, plane_bitangent, plane_tangent,
};
use crate::subgizmo::{SubGizmo, SubGizmoConfig, SubGizmoState, TransformKind};
use crate::{GizmoDirection, GizmoMode, GizmoResult, Ray};
Expand Down Expand Up @@ -56,7 +56,7 @@ impl SubGizmo for ScaleSubGizmo {
(TransformKind::Axis, _) => self.local_normal(),
(TransformKind::Plane, GizmoDirection::Screen) => DVec3::ONE,
(TransformKind::Plane, _) => {
(plane_binormal(self.direction) + plane_tangent(self.direction)).normalize()
(plane_bitangent(self.direction) + plane_tangent(self.direction)).normalize()
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/subgizmo/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::math::{intersect_plane, ray_to_ray, round_to_interval};

use crate::subgizmo::common::{
draw_arrow, draw_circle, draw_plane, inner_circle_radius, pick_arrow, pick_circle, pick_plane,
plane_binormal, plane_global_origin, plane_tangent,
plane_bitangent, plane_global_origin, plane_tangent,
};
use crate::subgizmo::{SubGizmo, SubGizmoConfig, SubGizmoState, TransformKind};
use crate::{GizmoDirection, GizmoMode, GizmoResult, Ray};
Expand Down Expand Up @@ -129,20 +129,20 @@ fn snap_translation_vector(subgizmo: &SubGizmoConfig<TranslationState>, new_delt
}

fn snap_translation_plane(subgizmo: &SubGizmoConfig<TranslationState>, new_delta: DVec3) -> DVec3 {
let mut binormal = plane_binormal(subgizmo.direction);
let mut bitangent = plane_bitangent(subgizmo.direction);
let mut tangent = plane_tangent(subgizmo.direction);
if subgizmo.config.local_space() {
binormal = subgizmo.config.rotation * binormal;
bitangent = subgizmo.config.rotation * bitangent;
tangent = subgizmo.config.rotation * tangent;
}
let cb = new_delta.cross(-binormal);
let cb = new_delta.cross(-bitangent);
let ct = new_delta.cross(tangent);
let lb = cb.length();
let lt = ct.length();
let n = subgizmo.normal();

if lb > 1e-5 && lt > 1e-5 {
binormal * round_to_interval(lt, subgizmo.config.snap_distance as f64) * (ct / lt).dot(n)
bitangent * round_to_interval(lt, subgizmo.config.snap_distance as f64) * (ct / lt).dot(n)
+ tangent
* round_to_interval(lb, subgizmo.config.snap_distance as f64)
* (cb / lb).dot(n)
Expand Down

0 comments on commit b05bcd9

Please sign in to comment.