Skip to content

Commit

Permalink
EdgeHandle : Tooltip track edge, not cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Oct 23, 2023
1 parent f7c55e9 commit d212df2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
15 changes: 12 additions & 3 deletions src/GafferSceneUI/LightTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}

Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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<LinearDrag> m_drag;
};

Expand Down

0 comments on commit d212df2

Please sign in to comment.