From d212df22ff2f802a770cf6753b649a4b10d45448 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 17 Oct 2023 12:09:10 -0400 Subject: [PATCH] EdgeHandle : Tooltip track edge, not cursor --- Changes.md | 2 +- src/GafferSceneUI/LightTool.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Changes.md b/Changes.md index 00d769df351..f1d2b4969cb 100644 --- a/Changes.md +++ b/Changes.md @@ -11,7 +11,7 @@ Features Improvements ------------ -- LightTool : Changed spot light tool tip location so that it follows the cone during drag. +- LightTool : Changed spot light and quad light edge tool tip locations so that they follow the cone and edge during drag. Fixes ----- diff --git a/src/GafferSceneUI/LightTool.cpp b/src/GafferSceneUI/LightTool.cpp index 3959afbd277..de87b08b539 100644 --- a/src/GafferSceneUI/LightTool.cpp +++ b/src/GafferSceneUI/LightTool.cpp @@ -2044,10 +2044,12 @@ class EdgeHandle : public LightToolHandle m_oppositeScaleAttributeName( oppositeScaleAttributeName ), m_edgeMargin( edgeMargin ), m_tipPlugSuffix( tipPlugSuffix ), + m_edgeScale( 1.f ), m_oppositeScale( 1.f ), m_orientation(), - m_oppositeAdditionalScale( 1.f ) + m_oppositeAdditionalScale( 1.f ), + m_tooltipT( 0 ) { } @@ -2234,8 +2236,14 @@ class EdgeHandle : public LightToolHandle edgeSegment.p1 += offset; edgeSegment *= m_orientation; - V3f eventClosest; - setTooltipPosition( edgeSegment.closestPoints( LineSegment3f( eventLine.p0, eventLine.p1 ), eventClosest ) ); + if( !m_drag ) + { + V3f eventClosest; + const V3f closestPoint = edgeSegment.closestPoints( LineSegment3f( eventLine.p0, eventLine.p1 ), eventClosest ); + m_tooltipT = ( closestPoint - edgeSegment.p0 ).length() / edgeSegment.length(); + } + + setTooltipPosition( edgeSegment( m_tooltipT ) ); } private : @@ -2307,6 +2315,7 @@ class EdgeHandle : public LightToolHandle float m_oppositeScale; M44f m_orientation; float m_oppositeAdditionalScale; + float m_tooltipT; // Parameter `t` along the edge set at the start of the drag std::optional m_drag; };