Nuke binary plugins 15.0.5
 
Loading...
Searching...
No Matches
DD::Image::GeomOpEngine Class Reference

#include <GeomOp.h>

Inheritance diagram for DD::Image::GeomOpEngine:
DD::Image::ModifyGeomOp::ModifyEngine DD::Image::SourceGeomOp::SourceEngine

Classes

class  InputBinding
 
class  KnobBinding
 

Public Types

using Builder = std::function< GeomOpEngine *(Op *)>
 'parent' is automatically provided when the first GeomOpEngine request is made.
 
using OpInput = std::pair< Op *, OutputContext >
 Combination of input Op and its OutputContext when cached in map.
 
using OpInputTimeMap = std::map< double, OpInput >
 
using OpInputTimeMapList = std::vector< OpInputTimeMap >
 
using OpInputTimeWarpMap = std::map< double, double >
 
using InputBindingList = std::vector< InputBinding >
 

Public Member Functions

std::string name () const override
 
OpfirstOp () const
 
void addMemberGeomOp (GeomOp *geop)
 Add to the node's GeomOp member set.
 
void removeMemberGeomOp (GeomOp *geop)
 Remove from the node's GeomOp member set.
 
const GeomOpSet & memberGeomOps () const
 
GeomOpgeomOpAt (double frame, int32_t view=-1) const
 
GeomOpgeomOpAtContext (const OutputContext &context) const
 Same as geomOpAt() but takes OutputContext.
 
GeomOpSet geomOpsFor (const std::set< int32_t > &views, const fdk::TimeValueSet &times) const
 Find all the GeomOps matching the views and times.
 
KnobBinding knob (const char *knob_name) const
 Return a read handle to the named Knob from the engine.
 
template<typename T >
getValue (const KnobBinding &knob) const
 Convenience method to get a value from a KnobBinding, if it's valid.
 
template<typename T >
getValue (const char *knobName) const
 Convenience method to get a value from a named Knob, if it exists.
 
template<typename T >
getValue (const T &defaultValue, const char *knobName, double frame, int view=-1) const
 Convenience method to get a value from a named Knob, if it exists, otherwise return defaultValue.
 
template<typename T >
getValue (const T &defaultValue, const char *knobName) const
 getValue() variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
template<typename T >
void getValue (T &v, const char *knobName, double frame, int view=-1) const
 
template<typename T >
void getValue (T &v, const char *knobName) const
 getValue(&T) variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
template<typename T >
getValue (const T &defaultValue, const KnobBinding &knob, double frame, int view=-1) const
 Convenience method to get a value from a KnobBinding, if it's valid, otherwise return defaultValue.
 
template<typename T >
getValue (const T &defaultValue, const KnobBinding &knob) const
 getValue() variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
OpinputOpAt (uint32_t node_input, double frame, const OutputContext &ctx)
 
OpinputOpAt (uint32_t node_input, double frame, int32_t view=-1)
 
size_t nInputs () const override
 
size_t nInputOps () const
 Returns the sum of all InputBinding op_split_counts.
 
const InputBindinginputBinding (uint32_t node_input)
 
GeomEngine * inputEngine (uint32_t node_input) override
 
GeomEngine * inputEngine0 () override
 
GeomEngine * inputEngine1 () override
 
OpinputBaseOp (uint32_t node_input)
 
void printInputBindings (std::ostream &, const char *prefix="") const
 Prints the contents of the current InputBindings.
 
void mergeFromInputs (usg::GeomSceneContext &context, const std::vector< int32_t > &inputs) override
 
void mergeFromInputs (usg::GeomSceneContext &context, int input, int count)
 
void processScenegraph (usg::GeomSceneContext &context) override
 This just sets the nuke:node data on the edit layer so we can go back from the Layer to the Node that created it.
 
void updateGeomEngineState (const usg::ArgSet &request_args, const GeomOpSet &geops, fdk::TimeValueSet &active_times)
 
const fdk::Hash & lastRequestHash () const
 
void setRequestHash (const fdk::Hash &hash)
 Assign the value of the request hash, usually done in GeomOp::buildStage().
 

Protected Member Functions

 GeomOpEngine (Op *parent)
 
virtual usg::Path importShaderOp (bool create_mode, usg::GeomSceneContext &scene_context, const std::vector< Op * > &source_ops, uint32_t material_group_index, const usg::Path &material_library_path)
 
virtual usg::Path importLightOp (bool create_mode, usg::GeomSceneContext &scene_context, const std::vector< LightOp * > &source_light_ops, const usg::Path &light_prim_path, const usg::Path &material_library_path=usg::Path())
 
virtual void assignMaterialBinding (usg::GeomSceneContext &context, bool create_mode, const usg::Path &material_path, const usg::PathArray &primPaths)
 

Protected Attributes

Op_firstOp
 Op that's guaranteed to exist and offer access to Nuke Node.
 
GeomOpSet _memberGeomOps
 All GeomOps sharing this engine - NOT the current active engine set!
 
fdk::Hash _lastVersionsHash
 The last combined GeomOp versions hashes.
 
fdk::Hash _lastRequestHash
 The last combined GeomOp hashes passed to the most recent buildStage()
 
usg::ShaderDescGroupPtrMap _shaderDescGroups
 Groups of locally-created ShaderDescs.
 

Friends

class GeomOp
 

Detailed Description

Scenegraph processing engine node that can build a usg::Stage. One of these is created and shared between all GeomOps generated from the same Nuke Node.

Member Function Documentation

◆ name()

std::string GeomOpEngine::name ( ) const
override

Default returns nodeName() from _firstOp. Since the name of the Nuke Node can change dynamically we don't save this string locally.

References _firstOp, DD::Image::Op::node(), and DD::Image::Op::nodeName().

Referenced by DD::Image::GeomOp::buildStage(), importLightOp(), importShaderOp(), mergeFromInputs(), DD::Image::SourceGeomOp::SourceEngine::processScenegraph(), and updateGeomEngineState().

◆ firstOp()

Op * DD::Image::GeomOpEngine::firstOp ( ) const
inline

Only use this to access values that ALL GeomOp instances would share, ie non-animating, non-viewsplit values, or to access Nuke Node methods.

Referenced by processScenegraph(), and DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ memberGeomOps()

const GeomOpSet & DD::Image::GeomOpEngine::memberGeomOps ( ) const
inline

Read access to all member GeomOps assigned to this engine. Note that some GeomOps may be disabled by Nuke and should not be assumed to be usable just because they're in this set. If the GeomOp's OutputContext view is < 0 (usually -1) then it is disabled and not usable.

◆ geomOpAt()

GeomOp * GeomOpEngine::geomOpAt ( double  frame,
int32_t  view = -1 
) const

Retrieve a valid GeomOp instance sharing this engine. This iterates over the _memberGeomOps set skipping disabled GeoOps (ones with outputContext().view() = -1,) so it's not the quickest routine.

No mutex lock is performed on set read - it's assumed that adding GeomOp instances is done on the main thread calls in GeomOp engineBuilder ctors().

Only use these GeomOps to access values that ALL instances would share, usually non-animating, non-viewsplit values, or non-Knob related methods.

The frame number is rounded to three decimal places (ie .001, a thousandth of a frame) to make it more likely that a match will occur. If view is non-valid then the 'main' view (view index 1) is used instead.

References _memberGeomOps.

Referenced by geomOpAtContext().

◆ inputOpAt() [1/2]

Op * GeomOpEngine::inputOpAt ( uint32_t  node_input,
double  frame,
const OutputContext ctx 
)

Returns an Op for input node_input at a specific frame and OutputContext (for the view and other context vars,) generating the Op if it's not already cached.

This method does not limit access to input Ops only via the limited number of shared GeomOp instances so the engine is free to access inputs at arbitrary times, bearing in mind the possible performance costs of doing so. If an Op does not already exist Op::node_input() is called with EXECUTABLE_INPUT mode to create it. For complex/large Op graphs this can be costly as the Op's inputs may also need to be generated.

Note - the frame number in the ctx arg is -ignored- and the frame arg is always used. The frame number is rounded to three decimal places (ie .001, a thousandth of a frame) to make it more likely that a subsequent retrieval match will occur. If frame is the 'default' frame value this returns the first Op in the list, usually the earliest in time.

Not thread safe - assuming this is called on main thread.

References _firstOp, DD::Image::Op::EXECUTABLE_INPUT, DD::Image::GeomOpEngine::InputBinding::inputFrameForOpTime(), DD::Image::GeomOpEngine::InputBinding::isValid(), DD::Image::Op::node_input(), DD::Image::GeomOpEngine::InputBinding::opsForView(), and DD::Image::Op::outputContext().

Referenced by inputOpAt(), and DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ inputOpAt() [2/2]

Op * GeomOpEngine::inputOpAt ( uint32_t  node_input,
double  frame,
int32_t  view = -1 
)

Same as inputOpAt() but for a single view. If view is -1 (invalid) then the 'main' view (view index 1) is used instead.

Not thread safe - assuming this is called on main thread.

References inputOpAt().

◆ nInputs()

size_t DD::Image::GeomOpEngine::nInputs ( ) const
inlineoverride

Return the number of Node InputBinding connections. Note that these are NOT Op inputs. The total number of Op inputs this Node produces can be found by totalling the op_split_count of all InputBindings, which is what nInputOps() returns.

◆ inputBinding()

const GeomOpEngine::InputBinding & GeomOpEngine::inputBinding ( uint32_t  node_input)

Returns the InputBinding for the node_input. If node_input is out of range an invalid InputBinding is returned.

◆ inputEngine()

GeomEngine * DD::Image::GeomOpEngine::inputEngine ( uint32_t  node_input)
inlineoverride

Returns the GeomOpEngine pointer from the node_input InputBinding. This will be null if the input is not a GeomOp Node or an empty GeomOpEngine (a NullGeomOp) if the input is disconnected.

Referenced by mergeFromInputs(), and DD::Image::ModifyGeomOp::ModifyEngine::updateFilteredPrimPaths().

◆ inputBaseOp()

Op * DD::Image::GeomOpEngine::inputBaseOp ( uint32_t  node_input)
inline

Returns the Op::firstOp() pointer from the node_input InputBinding. Warning, the firstOp may not be valid for a specific OutputContext that the engine is processing. It is ok to use for generic Node or Knob queries and Node input info - see the Op::firstOp() method for more info.

Use inputOpAt() and inputOpAtContext() to get a specific valid input Op.

Referenced by mergeFromInputs().

◆ mergeFromInputs() [1/2]

void GeomOpEngine::mergeFromInputs ( usg::GeomSceneContext &  context,
const std::vector< int32_t > &  inputs 
)
override

Merges the layers from the list of inputs into the _rootLayer. These are merged in reverse order.

References inputBaseOp(), inputEngine(), name(), and DD::Image::Op::nodeName().

Referenced by mergeFromInputs(), and DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ mergeFromInputs() [2/2]

void GeomOpEngine::mergeFromInputs ( usg::GeomSceneContext &  context,
int  input,
int  count 
)

Merges the layers from input up to input + count into the _rootLayer. These are merged in reverse order.

References mergeFromInputs().

◆ updateGeomEngineState()

void GeomOpEngine::updateGeomEngineState ( const usg::ArgSet &  request_args,
const GeomOpSet &  geops,
fdk::TimeValueSet &  active_times 
)

Update the state of the GeomOpEngine in preparation for calling buildScenegraph() and processScenegraph().

The GeomOpSet is the set of desired GeomOps that should be used to update the engine's state, and active_times will be filled in for each valid GeomOp that gets used to construct the state.

This method then calls the base class GeomEngine::validateGeomState() and any local GeomState changes will be reflected in the engine's dirty status.

References _lastVersionsHash, _memberGeomOps, _shaderDescGroups, DD::Image::Op::geomOp(), DD::Image::GeomOp::localTargets(), name(), DD::Image::Op::nodeName(), DD::Image::Op::outputContext(), DD::Image::root_real_fps, DD::Image::Op::treeVersion(), updateGeomEngineState(), and DD::Image::Op::validate().

Referenced by DD::Image::GeomOp::buildStage(), and updateGeomEngineState().

◆ lastRequestHash()

const fdk::Hash & DD::Image::GeomOpEngine::lastRequestHash ( ) const
inline

The 'request' hash is used to track the evaluation or configuration state of the GeomEngine by the GeomOp network.

The request hash is built in GeomOp::buildStage() from the set of GeomOps passed to it. If those GeomOps are the same and their hashes haven't changed, then the state of the GeomEngine and its input network is assumed to be unchanged.

Referenced by DD::Image::GeomOp::buildStage().

◆ importShaderOp()

usg::Path GeomOpEngine::importShaderOp ( bool  create_mode,
usg::GeomSceneContext &  scene_context,
const std::vector< Op * > &  source_ops,
uint32_t  material_group_index,
const usg::Path &  material_library_path 
)
protectedvirtual

Converts the input Op(s) to surface shader and material Prims, defined in the edit Layer anchored under material_library_path.

When create_mode is false this method will update any existing overrides for the shader and material prims that were created during the create_mode=true phase. Overrides are only written if the shader/material parameters are not at their inital default.

If the supplied Ops are ShaderOps (have a MaterialOpI interface) then the shaders are created through that interface. If the input is an Iop then it's treated as a texture source to a default constant (albedo only) shader. Legacy Material ops are NOT supported and will be ignored.

The material_group_index is used to track the 'output' ShaderDesc from each material graph in the _shaderDescGroups map, but it doesn't need to match an actual GeomOpEngine input number. Typically there will be only one input material graph so material_group_index will usually be 0.

Returns the path to the created or updated MaterialPrim, if successful.

References _shaderDescGroups, DD::Image::MaterialOpI::clearOverrideOp(), DD::Image::MaterialOpI::createShaderGraph(), DD::Image::MaterialOpI::MaterialContext::frame, DD::Image::MaterialOpI::getNodeInstanceSuffix(), DD::Image::MaterialOpI::getOutputType(), name(), DD::Image::Op::node(), DD::Image::Op::nodeFullPath(), DD::Image::Op::nodeName(), DD::Image::Op::nodeTopologyHash(), DD::Image::MaterialOpI::OUTPUT_TYPE_COSHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_LIGHTSHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_SURFACESHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_VOLUMESHADER, DD::Image::Op::outputContext(), DD::Image::MaterialOpI::setOverrideOp(), DD::Image::MaterialOpI::updateShaderGraphOverrides(), and DD::Image::MaterialOpI::MaterialContext::view.

Referenced by DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ importLightOp()

usg::Path GeomOpEngine::importLightOp ( bool  create_mode,
usg::GeomSceneContext &  scene_context,
const std::vector< LightOp * > &  source_light_ops,
const usg::Path &  light_prim_path,
const usg::Path &  material_library_path = usg::Path() 
)
protectedvirtual

Converts the input LightOp(s) to a usg::LightPrim and any associated shaders, defined in the edit Layer anchored under light_anchor_path.

If the LightOp has 'surface' shader inputs (texture sources really) they will be anchored under 'material_library_path'.

Returns the path to the created or updated MaterialPrim, if successful.

References _shaderDescGroups, DD::Image::LightOp::asLightMaterialOp(), DD::Image::MaterialOpI::createShaderGraph(), DD::Image::LightMaterialOpI::defineLightPrim(), name(), DD::Image::Op::nodeFullPath(), DD::Image::Op::nodeName(), DD::Image::MaterialOpI::OUTPUT_TYPE_LIGHTSHADER, DD::Image::Op::outputContext(), and DD::Image::MaterialOpI::updateShaderGraphOverrides().

◆ assignMaterialBinding()

void GeomOpEngine::assignMaterialBinding ( usg::GeomSceneContext &  context,
bool  create_mode,
const usg::Path &  material_path,
const usg::PathArray &  primPaths 
)
protectedvirtual

Assign the material to a list of Prims. Companion method to importShaderOp() usually called after it to assign the created material to a list of previously-created Prims.

When create_mode is true each Prim is retrieved from the engine's editLayer() and a Relationship created on the Prim. When create_mode is false each Prim is retrieved from the composed stage flowing through this node, and a Relationship matching material_path is searched for and updated.

Referenced by DD::Image::SourceGeomOp::SourceEngine::processScenegraph().



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com