Skip to content

Commit

Permalink
fixup! LightTool : Refactor WidthHeightHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Oct 3, 2023
1 parent 98d314c commit edc7f3d
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions src/GafferSceneUI/LightTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,6 @@ class SpotLightHandle : public LightToolHandle
return m_handleType == HandleType::Cone ? "cone angles" : "penumbra angles";
}

private :

void handlePathChanged() override
{
ConstCompoundObjectPtr attributes = scene()->fullAttributes( handlePath() );
Expand Down Expand Up @@ -1684,31 +1682,6 @@ class SpotLightHandle : public LightToolHandle
return true;
}

bool mouseMove( const ButtonEvent &event )
{
if( !hasInspectors() || m_drag )
{
return false;
}

const auto &[coneHandleAngle, penumbraHandleAngle] = handleAngles();

const float angle = m_handleType == HandleType::Cone ? coneHandleAngle : penumbraHandleAngle.value();

const M44f r = M44f().rotate( V3f( 0, degreesToRadians( angle ), 0 ) );
const Line3f rayLine(
V3f( 0 ),
V3f( 0, 0, m_visualiserScale * m_frustumScale * -10.f ) * r
);
const V3f dragPoint = rayLine.closestPointTo( Line3f( event.line.p0, event.line.p1 ) );
setTooltipPosition( dragPoint );
m_arcRadius = dragPoint.length();

dirty( DirtyType::Render );

return false;
}

void setupDrag( const DragDropEvent &event ) override
{
m_drag = AngularDrag(
Expand Down Expand Up @@ -1763,6 +1736,33 @@ class SpotLightHandle : public LightToolHandle
return result;
}

private :

bool mouseMove( const ButtonEvent &event )
{
if( !hasInspectors() || m_drag )
{
return false;
}

const auto &[coneHandleAngle, penumbraHandleAngle] = handleAngles();

const float angle = m_handleType == HandleType::Cone ? coneHandleAngle : penumbraHandleAngle.value();

const M44f r = M44f().rotate( V3f( 0, degreesToRadians( angle ), 0 ) );
const Line3f rayLine(
V3f( 0 ),
V3f( 0, 0, m_visualiserScale * m_frustumScale * -10.f ) * r
);
const V3f dragPoint = rayLine.closestPointTo( Line3f( event.line.p0, event.line.p1 ) );
setTooltipPosition( dragPoint );
m_arcRadius = dragPoint.length();

dirty( DirtyType::Render );

return false;
}

std::pair<float, std::optional<float>> handleAngles() const
{
InspectionInfo coneHandleInfo;
Expand Down Expand Up @@ -1922,7 +1922,7 @@ class EdgeHandle : public LightToolHandle

}

private :
protected :

bool handleDragMoveInternal( const GafferUI::DragDropEvent &event ) override
{
Expand Down Expand Up @@ -2046,6 +2046,8 @@ class EdgeHandle : public LightToolHandle
return "";
}

private :

bool mouseMove( const ButtonEvent &event )
{
if( !hasInspectors() )
Expand Down Expand Up @@ -2197,7 +2199,7 @@ class CornerHandle : public LightToolHandle

}

private :
protected :

bool handleDragMoveInternal( const GafferUI::DragDropEvent &event ) override
{
Expand Down Expand Up @@ -2340,6 +2342,8 @@ class CornerHandle : public LightToolHandle
return "Hold Ctrl to maintain aspect ratio";
}

private :

bool mouseMove( const ButtonEvent &event )
{
if( !hasInspectors() )
Expand Down

0 comments on commit edc7f3d

Please sign in to comment.