Oh dear, I just missed a break statement when declaring the phases. Move on, nothing to see here...
On Thu, Jul 4, 2013 at 4:11 PM, Leonard Koch <leonardkoch...@gmail.com>wrote: > Hi, > > When I set up a multi-phase ice-node according to the specifications set > on the webpage linked below in_ctxt.GetEvaluationPhaseIndex( ); returns -1 > and I naturally none of the phase switch parts get executed. > > http://download.autodesk.com/global/docs/softimage2013/en_us/sdkguide/index.html?url=files/cus_icenodes_MultiPhaseCustomICENode.htm,topicNumber=d30e19848 > > Below is a simplified version of my SubmitEvaluationPhaseInfo and Evaluate > callbacks. > > If you run it, this is the output: > # INFO : Reached beginning of Evaluate callback. > # INFO : -1 > # INFO : Reached multi-threaded part of Evaluate callback > And that repeated for every thread. > So the part before the phase switch and after is being evaluated, but the > part inside of it isn't because ULONG nPhase = > in_ctxt.GetEvaluationPhaseIndex( ); apparently returns -1. > I've gone over everything 10 times and in my eyes everything is set up > correctly, but clearly I'm making a mistake somewhere. > I would really appreciate it if somebody experienced would take a look. > > I've also attached the entire c++ file. > > Thank you so much guys. > > SICALLBACK GetTextureColorByUV_SubmitEvaluationPhaseInfo( ICENodeContext& > in_ctxt ) > { > ULONG nPhase = in_ctxt.GetEvaluationPhaseIndex( ); > > // Note: A case statement is needed for each phase we want to define. Each > phase should submit one or multiple ports to > // process. Be sure to call in_ctxt.SetLastEvaluationPhase() to specify > the last phase to process. > switch( nPhase ) > { > case 0: > { > // Example for pulling a port for evaluation. > in_ctxt.AddEvaluationPhaseInputPort( ID_IN_ImagePath ); > } > case 1: > { > // Example for pulling a port for evaluation. > in_ctxt.AddEvaluationPhaseInputPort( ID_IN_U ); > in_ctxt.AddEvaluationPhaseInputPort( ID_IN_V ); > // Tells XSI that phase 1 is the last phase to process > in_ctxt.SetLastEvaluationPhase(); > } > break; > > default: > // Abort evaluation if the current phase is not handled > return CStatus::Abort; > } > return CStatus::OK; > } > > SICALLBACK GetTextureColorByUV_Evaluate( ICENodeContext& in_ctxt ) > { > // Code sample to demonstrate how to implement a multi-phase evaluation > callback. > // Process all phases first. The Evaluate callback is called in > single-threading > // for each phase declared in the > GetTextureColorByUV_SubmitEvaluationPhaseInfo callback. > ULONG nPhase = in_ctxt.GetEvaluationPhaseIndex( ); > * Application().LogMessage("Reached multi-threaded part of Evaluate > callback"); > * > * Application().LogMessage(CString(nPhase));* > switch( nPhase ) > { > // Note: A case statement is needed here for each phase declared in > GetTextureColorByUV_SubmitEvaluationPhaseInfo > case 0: > { > CDataArrayString ImagePathData( in_ctxt, ID_IN_ImagePath ); > * Application().LogMessage("Reached End of phase");* > // Store results in user data ... > return CStatus::OK; > } > case 1: > { > return CStatus::OK; > } > break; > }; > > // Note: The last phase is always processed in multi-threading. > ULONG out_portID = in_ctxt.GetEvaluatedOutputPortID( ); > > switch( out_portID ) > { > case ID_OUT_Color : > { > // Get the output port array ... > CDataArray2DColor4f outData( in_ctxt ); > > // Get the input data buffers for each port > CDataArray2DFloat UData( in_ctxt, ID_IN_U ); > CDataArray2DFloat VData( in_ctxt, ID_IN_V ); > > * Application().LogMessage("Reached multi-threaded part of Evaluate > callback");* > > // We need a CIndexSet to iterate over the data > CIndexSet indexSet( in_ctxt ); > for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next()) > { > // Add code to set output port... > CDataArray2DFloat::Accessor USubArray = UData[it]; > CDataArray2DFloat::Accessor VSubArray = VData[it]; > CDataArray2DColor4f::Accessor outDataSubArray = > outData.Resize(it, USubArray.GetCount()); > > for (ULONG i=0; i<USubArray.GetCount( ); i++) > { > outDataSubArray[i].PutR(1); > outDataSubArray[i].PutG(1); > outDataSubArray[i].PutB(1); > outDataSubArray[i].PutA(1); > } > } > } > break; > }; > > return CStatus::OK; > } > > > >