Now, say that computing these quantities from input1 is heavy enough such that they should really only be re-computed when input1 changes. First question is, is there a way to detect/track when an input changes? And, is there any granularity to the changes that can be detected? e.g. the points value has changed. vs the connection has been re-wired to different geometry etc?
int changed; duplicateChangedSource(1, context, &changed);
The above apparently allows me to know when input1 has changed (btw, what is the definition of "changed"?) but I don't actually want to have the node output input1's geometry - the SOP just wants to deform input0. Is there a better way?
Second question is, say my computed quantities from input2 are wrapped in my own custom class FooData. It is data that doesn't need to persist across houdini sessions - no need to record it as an attribute the node. Imagine it's something like an octree. Is it kosher to have my SOP just keep a handle to an instance of that class? e.g.
class SOP_Foo { public: ... private: FooData *m_data; // some data that needs be re-computed whenever input2 changes. // should NOT be recomputed each time sop is cooked. } Sop_Foo::cookMySop(OP_Context &context) { ... if (!m_data) { m_data = new FooData(); m_data->doSomeHeavyComputation(); } }
Is it fine during the cooking of my SOP to read/write that m_data member? Or does houdini do multi-threaded(across points?) cooking and this is a race condition? Thank you in advance.