Alright, I thought I was in the clear, but I’m still running into an issue and I’d like to (once again) get some more experienced eyes on my code to make sure I’m not doing anything too dumb.
My plugin works fine now, except in some scripts. When I try to render using Nuke -x, things start normally, but then die with: Warning: Reformat1: get(channels=0x7), but request(channels=0x1) If I use a Python wrapper script and call it using Nuke -t, I get the ever-verbose "RuntimeError: Cancelled" following the channel warning message. Here’s my updated code (trimmed as much as seemed reasonable): ---------------------------- class AverageChannels : public Iop { Lock _engineLock; ChannelSet _opChannels; bool _firstTime; double _pixAggregate[3]; float _avgPix[3]; //............ void knobs(Knob_Callback f) { InputOnly_ChannelSet_knob(f, &_opChannels, 0, "channels"); Tooltip(f, "Which channels to average."); } void _validate(bool for_real) { _firstTime = true; copy_info(); set_out_channels(_opChannels); Iop::_validate(for_real); } void _request(int x, int y, int r, int t, ChannelMask channels, int count) { input0().request(x, y, r, t, channels, count); } void engine(int y, int x, int r, ChannelMask channels, Row& out) { if (!intersect(_opChannels, channels)) { input0().get(y, x, r, channels, out); return; } ChannelSet unchanged(channels); unchanged -= _opChannels; input0().get(y, x, r, unchanged, out); if (_firstTime) { Guard g(_engineLock); if (_firstTime) { // Reinitialize value containers for (int i = 0; i < _opChannels.size(); i++) { _avgPix[i] = _pixAggregate[i] = 0.0f; } // Input image dimensions and info Format format = input0().format(); const int fx = format.x(); const int fy = format.y(); const int fr = format.r(); const int ft = format.t(); const int height = ft - fy; const int width = fr - fx; const unsigned long int pixCount = width * height; for (int ry = fy; ry < ft; ry++) { // Set any progress bars progressFraction(ry, ft - fy); Row row(fx, fr); row.get(input0(), ry, fx, fr, _opChannels); if (aborted()) return; // Aggregate pixel values from _opChannels into container array int chan = 0; foreach(z, _opChannels) { const float *CUR = row[z] + fx; const float *END = row[z] + fr; while (CUR < END) { _pixAggregate[chan] += (float)*CUR++; } chan++; } } // Calculate the average for each channel for (int c = 0; c < _opChannels.size(); c++) { _avgPix[c] = _pixAggregate[c] / pixCount; } _firstTime = false; } } // Lock out of scope if (aborted()) return; int outChan = 0; foreach(z, _opChannels) { float *CUR = out.writable(z) + x; const float *END = out[z] + r; while (CUR < END) { *CUR++ = _avgPix[outChan]; } outChan++; } } }; -Nathan From: Steven Booth Sent: Monday, October 31, 2011 4:56 PM To: Nuke plug-in development discussion Subject: RE: [Nuke-dev] Altering only a specific ChannelSet in engine No worries, Nathan! It’s why the Forums are so invaluable. Steve From: nuke-dev-boun...@support.thefoundry.co.uk [mailto:nuke-dev-boun...@support.thefoundry.co.uk] On Behalf Of Nathan Rusch Sent: Monday, October 31, 2011 4:54 PM To: Nuke plug-in development discussion Subject: Re: [Nuke-dev] Altering only a specific ChannelSet in engine 10 minute rewrite and it’s all working perfectly. Thanks for your info guys... huge informational leap. -Nathan
_______________________________________________ Nuke-dev mailing list Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev