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 17, 2023
1 parent b175482 commit 7270fe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Improvements
- Spreadsheet :
- Popups for string cells and row names are now sized to fit their column.
- Added "Triple" and "Quadruple" width options to the spreadsheet row name popup menu.
- 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.

1.3.4.0 (relative to 1.3.3.0)
=======
Expand Down
12 changes: 10 additions & 2 deletions src/GafferSceneUI/LightTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,7 @@ class EdgeHandle : public LightToolHandle
m_edgeScale( 1.f ),
m_oppositeScale( 1.f ),
m_orientation(),
m_tooltipT( 0 ),
m_oppositeAdditionalScale( 1.f )
{
}
Expand Down Expand Up @@ -2245,8 +2246,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 @@ -2318,6 +2325,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 7270fe2

Please sign in to comment.