ActionRetCodeEnum DiskCacheNode::getFrameRange(double *first, double *last) { int idx = _imp->frameRange.lock()->getValue(); switch (idx) { case 0: { EffectInstancePtr input = getInputRenderEffectAtAnyTimeView(0); if (input) { GetFrameRangeResultsPtr results; ActionRetCodeEnum stat = input->getFrameRange_public(&results); if (isFailureRetCode(stat)) { return stat; } RangeD range; results->getFrameRangeResults(&range); *first = range.min; *last = range.max; } break; } case 1: { TimeValue left, right; getApp()->getProject()->getFrameRange(&left, &right); *first = left; *last = right; break; } case 2: { *first = _imp->firstFrame.lock()->getValue(); *last = _imp->lastFrame.lock()->getValue(); }; default: break; } return eActionStatusOK; }
ActionRetCodeEnum RotoShapeRenderNode::getRegionOfDefinition(TimeValue time, const RenderScale& scale, ViewIdx view, RectD* rod) { RotoDrawableItemPtr item = getAttachedRotoItem(); assert(item); assert((isRenderClone() && item->isRenderClone()) || (!isRenderClone() && !item->isRenderClone())); const bool isPainting = isDuringPaintStrokeCreation(); RectD shapeRoD; getRoDFromItem(item, time, view, isPainting, &shapeRoD); bool clipToFormat = _imp->clipToFormatKnob.lock()->getValue(); RotoShapeRenderTypeEnum type = (RotoShapeRenderTypeEnum)_imp->renderType.lock()->getValue(); switch (type) { case eRotoShapeRenderTypeSmear: { RectD defaultRod; ActionRetCodeEnum stat = EffectInstance::getRegionOfDefinition(time, scale, view, &defaultRod); if (isFailureRetCode(stat)) { return stat; } if (!defaultRod.isNull()) { *rod = shapeRoD; rod->merge(defaultRod); } } break; case eRotoShapeRenderTypeSolid: { RotoPaintOutputRoDTypeEnum rodType = (RotoPaintOutputRoDTypeEnum)_imp->outputRoDTypeKnob.lock()->getValue(); switch (rodType) { case eRotoPaintOutputRoDTypeDefault: { *rod = shapeRoD; // No format is set, use the format from the input if (clipToFormat) { EffectInstancePtr inputEffect = getInputRenderEffectAtAnyTimeView(0); if (inputEffect) { RectI outputFormat = inputEffect->getOutputFormat(); RectD outputFormatCanonical; outputFormat.toCanonical_noClipping(scale, inputEffect->getAspectRatio(-1), &outputFormatCanonical); rod->intersect(outputFormatCanonical, rod); } } } break; case eRotoPaintOutputRoDTypeFormat: { KnobIntPtr sizeKnob = _imp->outputFormatSizeKnob.lock(); int w = sizeKnob->getValue(DimIdx(0)); int h = _imp->outputFormatSizeKnob.lock()->getValue(DimIdx(1)); double par = _imp->outputFormatParKnob.lock()->getValue(); RectI pixelFormat; pixelFormat.x1 = pixelFormat.y1 = 0; pixelFormat.x2 = w; pixelFormat.y2 = h; RenderScale renderScale(1.); pixelFormat.toCanonical_noClipping(renderScale, par, rod); if (!clipToFormat) { rod->merge(shapeRoD); } } break; case eRotoPaintOutputRoDTypeProject: { Format f; getApp()->getProject()->getProjectDefaultFormat(&f); f.toCanonical_noClipping(RenderScale(1.), f.getPixelAspectRatio(), rod); if (!clipToFormat) { rod->merge(shapeRoD); } } break; } } break; } return eActionStatusOK; }
ActionRetCodeEnum RotoShapeRenderNode::getTimeInvariantMetadata(NodeMetadata& metadata) { assert(_imp->renderType.lock()); RotoShapeRenderTypeEnum type = (RotoShapeRenderTypeEnum)_imp->renderType.lock()->getValue(); int nComps; if (type == eRotoShapeRenderTypeSolid) { // If there's an input to the RotoShapeRender node, pass-through the meta-data number of components so that downstream nodes // have a good default color plane. // E.g: if we have Constant--> RotoShapeRender --> Merge, we want the Merge to have the number of components of the Constant EffectInstancePtr inputEffect = getInputRenderEffectAtAnyTimeView(0); if (inputEffect) { ImagePlaneDesc inputPlane, paireInputPlane; inputEffect->getMetadataComponents(-1, &inputPlane, &paireInputPlane); nComps = inputPlane.getNumComponents(); } else { nComps = 1; } } else { nComps = 4; } metadata.setColorPlaneNComps(-1, nComps); metadata.setColorPlaneNComps(0, nComps); // The roto can be sampled at any non integer time metadata.setIsContinuous(true); RotoPaintOutputRoDTypeEnum rodType = (RotoPaintOutputRoDTypeEnum)_imp->outputRoDTypeKnob.lock()->getValue(); switch (rodType) { case eRotoPaintOutputRoDTypeDefault: // No format is set break; case eRotoPaintOutputRoDTypeFormat: { KnobIntPtr sizeKnob = _imp->outputFormatSizeKnob.lock(); int w = sizeKnob->getValue(DimIdx(0)); int h = _imp->outputFormatSizeKnob.lock()->getValue(DimIdx(1)); double par = _imp->outputFormatParKnob.lock()->getValue(); RectI pixelFormat; pixelFormat.x1 = pixelFormat.y1 = 0; pixelFormat.x2 = w; pixelFormat.y2 = h; metadata.setPixelAspectRatio(-1, par); metadata.setOutputFormat(pixelFormat); } break; case eRotoPaintOutputRoDTypeProject: { Format f; getApp()->getProject()->getProjectDefaultFormat(&f); metadata.setPixelAspectRatio(-1, f.getPixelAspectRatio()); metadata.setOutputFormat(f); } break; } return eActionStatusOK; }