Skip to content

Commit

Permalink
SpotLightHandle : Enable for Gaffer USD spot light
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Oct 17, 2023
1 parent 1b7c5c3 commit dac26d5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/GafferSceneUI/LightTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ class SpotLightHandle : public LightToolHandle
LightToolHandle( lightType, view, { g_coneAngleParameter, g_penumbraAngleParameter }, name ),
m_zRotation( zRotation ),
m_handleType( handleType ),
m_angleMultiplier( 1.f ),
m_angleHandleRatio( 2.f ),
m_visualiserScale( 1.f ),
m_frustumScale( 1.f ),
m_lensRadius( 0 )
Expand Down Expand Up @@ -1602,11 +1602,11 @@ class SpotLightHandle : public LightToolHandle
auto angleType = Metadata::value<StringData>( shaderAttribute, "coneAngleType" );
if( angleType && angleType->readable() == "half" )
{
m_angleMultiplier = 2.f;
m_angleHandleRatio = 1.f;
}
else
{
m_angleMultiplier = 1.f;
m_angleHandleRatio = 2.f;
}

break;
Expand Down Expand Up @@ -1918,7 +1918,7 @@ class SpotLightHandle : public LightToolHandle
// Convert from the angle representation used by plugs to that used by handles.
float coneHandleAngle( const float angle ) const
{
return angle * 0.5f;
return angle / m_angleHandleRatio;
}

float penumbraHandleAngle( const float angle ) const
Expand All @@ -1932,7 +1932,7 @@ class SpotLightHandle : public LightToolHandle

float conePlugAngle(const float a ) const
{
return a * 2.f / m_angleMultiplier;
return a * m_angleHandleRatio;
}

float penumbraPlugAngle(const float a ) const
Expand Down Expand Up @@ -2006,7 +2006,7 @@ class SpotLightHandle : public LightToolHandle
HandleType m_handleType;
std::optional<InternedString> m_penumbraType;

float m_angleMultiplier;
float m_angleHandleRatio;

float m_visualiserScale;
float m_frustumScale;
Expand Down Expand Up @@ -3025,14 +3025,14 @@ LightTool::LightTool( SceneView *view, const std::string &name ) :

// Spotlight handles

m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Penumbra, view, 0, "westConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Cone, view, 0, "westPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Penumbra, view, 90, "southConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Cone, view, 90, "southPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Penumbra, view, 180, "eastConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Cone, view, 180, "eastPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Penumbra, view, 270, "northConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot", SpotLightHandle::HandleType::Cone, view, 270, "northPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Penumbra, view, 0, "westConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Cone, view, 0, "westPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Penumbra, view, 90, "southConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Cone, view, 90, "southPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Penumbra, view, 180, "eastConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Cone, view, 180, "eastPenumbraAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Penumbra, view, 270, "northConeAngleParameter" ) );
m_handles->addChild( new SpotLightHandle( "spot point", SpotLightHandle::HandleType::Cone, view, 270, "northPenumbraAngleParameter" ) );

// Quadlight handles

Expand Down

0 comments on commit dac26d5

Please sign in to comment.