Skip to content

Commit

Permalink
LightPositionTool : Avoid shadow naming
Browse files Browse the repository at this point in the history
I had originally envisioned more unique methods and variables for
shadow, specular, diffuse light placement modes, but now that I've
gotten into the details of the shadow mode, I don't see why they
couldn't all share pivot and target data. Changing this now will make
future modes easier to add.
  • Loading branch information
ericmehl committed Jan 4, 2024
1 parent b6c19dd commit 716c94a
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 110 deletions.
28 changes: 14 additions & 14 deletions include/GafferSceneUI/LightPositionTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class GAFFERSCENEUI_API LightPositionTool : public GafferSceneUI::TransformTool

// Positions the current selection to cast a shadow from `shadowPivot` to `shadowTarget`,
// with the light `targetDistance` from the pivot. All coordinates are in world space.
void position( const Imath::V3f &shadowPivot, const Imath::V3f &shadowTarget, const float targetDistance );
void positionShadow( const Imath::V3f &shadowPivot, const Imath::V3f &shadowTarget, const float targetDistance );

protected :

Expand Down Expand Up @@ -120,37 +120,37 @@ class GAFFERSCENEUI_API LightPositionTool : public GafferSceneUI::TransformTool
enum class TargetMode
{
None,
ShadowPivot,
ShadowTarget
Pivot,
Target
};

void setTargetMode( TargetMode mode );
TargetMode getTargetMode() const { return m_targetMode; }

void setShadowPivot( const Imath::V3f &p, Gaffer::ScriptNodePtr scriptNode );
std::optional<Imath::V3f> getShadowPivot() const;
void setShadowTarget( const Imath::V3f &p, Gaffer::ScriptNodePtr scriptNode );
std::optional<Imath::V3f> getShadowTarget() const;
void setShadowPivotDistance( const float d );
std::optional<float> getShadowPivotDistance() const;
void setPivot( const Imath::V3f &p, Gaffer::ScriptNodePtr scriptNode );
std::optional<Imath::V3f> getPivot() const;
void setTarget( const Imath::V3f &p, Gaffer::ScriptNodePtr scriptNode );
std::optional<Imath::V3f> getTarget() const;
void setPivotDistance( const float d );
std::optional<float> getPivotDistance() const;

TargetMode m_targetMode;

std::optional<TranslationRotation> m_drag;
float m_startShadowPivotDistance;
float m_startPivotDistance;

GafferUI::HandlePtr m_shadowHandle;
GafferUI::HandlePtr m_distanceHandle;
GafferUI::RotateHandlePtr m_rotateHandle;

Gaffer::Signals::ScopedConnection m_contextChangedConnection;

// Pivots and targets are stored in transform space - the world space transform
// of the scene in which the transform will be applied.
// See `TransformTool::transformSpace()` for details.
std::unordered_map<std::string, std::optional<Imath::V3f>> m_shadowPivotMap;
std::unordered_map<std::string, std::optional<Imath::V3f>> m_shadowTargetMap;
std::unordered_map<std::string, std::optional<Imath::V3f>> m_pivotMap;
std::unordered_map<std::string, std::optional<Imath::V3f>> m_targetMap;

std::unordered_map<std::string, std::optional<float>> m_shadowPivotDistanceMap;
std::unordered_map<std::string, std::optional<float>> m_pivotDistanceMap;

bool m_draggingTarget;

Expand Down
4 changes: 2 additions & 2 deletions python/GafferSceneUITest/LightPositionToolTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def testPosition( self ) :
upDir = script["light"]["transform"].matrix().multDirMatrix( imath.V3f( 0, 1, 0 ) )

with Gaffer.Context() :
tool.position( shadowPivot, shadowPoint, d0 )
tool.positionShadow( shadowPivot, shadowPoint, d0 )

p = script["light"]["transform"]["translate"].getValue()

Expand Down Expand Up @@ -166,7 +166,7 @@ def testPositionWithParentTransform( self ) :
d = ( worldP - shadowPivot ).length()

with Gaffer.Context() :
tool.position( shadowPivot, shadowPoint, d )
tool.positionShadow( shadowPivot, shadowPoint, d )

parentInverseTransform = script["group"]["out"].fullTransform( "/group" ).inverse()

Expand Down
Loading

0 comments on commit 716c94a

Please sign in to comment.