Enzo
Loading...
Searching...
No Matches
enzo::nt::NodeImpl Class Referenceabstract

The base class a node author subclasses to write a node's behaviour. More...

#include <NodeImpl.h>

Public Member Functions

 NodeImpl (Node &node, CookContext &context)
 
virtual void cook ()=0
 Produces this node's output packets from its inputs and parameters.
 

Protected Member Functions

void throwError (std::string error)
 Stops the cook and displays an error.
 
void throwWarning (std::string warning)
 Displays a warning on the node without interrupting the cook.
 
const std::filesystem::path & getNodeFolder () const
 Returns the folder the node was loaded from, where its assets live.
 
bool outputRequested (unsigned int outputIndex)
 Returns whether anything downstream is asking for this output.
 
void setOutputPacket (unsigned int outputIndex, enzo::NodePacket packet)
 Hands finished geometry to one of the node's outputs.
 
enzo::NodePacket cloneInputPacket (unsigned int inputIndex)
 Returns a writable copy of the geometry arriving at one input.
 
bool hasInput (unsigned int inputIndex)
 Returns whether an input has anything connected to it.
 
unsigned int getInputCount ()
 Returns how many inputs the node takes.
 
floatT getFrame () const
 Returns the frame the scene sits on.
 
floatT getTime () const
 Returns the scene time in seconds, measured from the start of frame 1.
 
floatT evalParmFloat (std::string_view parmName, const unsigned int index=0) const
 
intT evalParmInt (std::string_view parmName, const unsigned int index=0) const
 
boolT evalParmBool (std::string_view parmName, const unsigned int index=0) const
 
String evalParmString (std::string_view parmName, const unsigned int index=0) const
 
std::vector< floatT > evalParmFloats (std::string_view parmName) const
 
std::vector< intT > evalParmInts (std::string_view parmName) const
 
std::vector< String > evalParmStrings (std::string_view parmName) const
 
Vector2 evalParmVector2 (std::string_view parmName) const
 
Vector3 evalParmVector3 (std::string_view parmName) const
 
enzo::prm::Ramp evalParmRamp (std::string_view parmName) const
 Snapshots a ramp parameter into a sampler for use during the cook.
 

Detailed Description

The base class a node author subclasses to write a node's behaviour.

One of these is built for every cook and thrown away when the cook ends, so anything it stores is scoped to that cook and cannot leak into the next one. Cross cook state belongs on nt::Node instead, where the engine can invalidate it.

Example

class Circle : public nt::NodeImpl
{
using NodeImpl::NodeImpl;
void cook() override { setOutputPacket(0, buildMesh()); }
};
ENZO_REGISTER_NODE(circle, Circle)
The base class a node author subclasses to write a node's behaviour.
Definition NodeImpl.h:40
virtual void cook()=0
Produces this node's output packets from its inputs and parameters.
void setOutputPacket(unsigned int outputIndex, enzo::NodePacket packet)
Hands finished geometry to one of the node's outputs.
Definition NodeImpl.cpp:22
Note
Every cook time query lives here as a forwarder, so an author writes evalParmFloat("radius") and never names the context behind it.

Member Function Documentation

◆ cook()

virtual void enzo::nt::NodeImpl::cook ( )
pure virtual

Produces this node's output packets from its inputs and parameters.

Postcondition
Any output left unset stays an empty packet.

◆ getFrame()

floatT enzo::nt::NodeImpl::getFrame ( ) const
protected

Returns the frame the scene sits on.

Note
The frame can be fractional.

◆ getInputCount()

unsigned int enzo::nt::NodeImpl::getInputCount ( )
protected

Returns how many inputs the node takes.

Note
A multi input port holds one input per connection it has.

◆ outputRequested()

bool enzo::nt::NodeImpl::outputRequested ( unsigned int outputIndex)
protected

Returns whether anything downstream is asking for this output.

Todo
Always true until nt::Node tracks dirtiness per output.

◆ setOutputPacket()

void enzo::nt::NodeImpl::setOutputPacket ( unsigned int outputIndex,
enzo::NodePacket packet )
protected

Hands finished geometry to one of the node's outputs.

Todo
std::move the geometry instead of copying it.

◆ throwError()

void enzo::nt::NodeImpl::throwError ( std::string error)
protected

Stops the cook and displays an error.

Todo
Add visual error to GUI

◆ throwWarning()

void enzo::nt::NodeImpl::throwWarning ( std::string warning)
protected

Displays a warning on the node without interrupting the cook.

Todo
Add visual warning to GUI

The documentation for this class was generated from the following files: