Commit: 610a66bf8c547d084e61aac338976e3f312ee3c4 Author: Dalai Felinto Date: Tue Aug 26 02:42:10 2014 +0200 Branches: multiview https://developer.blender.org/rB610a66bf8c547d084e61aac338976e3f312ee3c4
Compositor: Image Node to work correctly with MultiView images =================================================================== M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/intern/image.c M source/blender/compositor/nodes/COM_ImageNode.cpp M source/blender/compositor/nodes/COM_ImageNode.h M source/blender/compositor/operations/COM_MultilayerImageOperation.cpp M source/blender/compositor/operations/COM_MultilayerImageOperation.h =================================================================== diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index e9f02e3..c83d1f3 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -196,9 +196,6 @@ void BKE_image_update_frame(const struct Main *bmain, int cfra); /* sets index offset for multilayer files */ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser); -/* sets index offset for multiview files */ -struct RenderPass *BKE_image_multiview_index(struct RenderResult *rr, struct ImageUser *iuser); - /* for multilayer images as well as for render-viewer */ bool BKE_image_is_stereo(struct Scene *scene, struct Image *ima); struct RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 832082d..d85d08f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2388,11 +2388,10 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) return NULL; if (iuser) { - short index = 0, rl_index = 0, rp_index; - short view; + short index = 0, rv_index, rl_index = 0, rp_index; bool is_stereo = RE_RenderResult_is_stereo(rr) && (iuser->flag & IMA_SHOW_STEREO); - view = is_stereo ? iuser->eye : iuser->view; + rv_index = is_stereo ? iuser->eye : iuser->view; for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) { rp_index = 0; @@ -2400,7 +2399,7 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) { if (iuser->layer == rl_index && iuser->passtype == rpass->passtype && - view == rpass->view_id) { + rv_index == rpass->view_id) { break; } } diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 5cca55e..5c238b2 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -39,19 +39,19 @@ ImageNode::ImageNode(bNode *editorNode) : Node(editorNode) } NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user, - int framenumber, int outputsocketIndex, int passindex, DataType datatype) const + int framenumber, int outputsocketIndex, int passtype, int view, DataType datatype) const { NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex); MultilayerBaseOperation *operation = NULL; switch (datatype) { case COM_DT_VALUE: - operation = new MultilayerValueOperation(passindex); + operation = new MultilayerValueOperation(passtype, view); break; case COM_DT_VECTOR: - operation = new MultilayerVectorOperation(passindex); + operation = new MultilayerVectorOperation(passtype, view); break; case COM_DT_COLOR: - operation = new MultilayerColorOperation(passindex); + operation = new MultilayerColorOperation(passtype, view); break; default: break; @@ -67,42 +67,6 @@ NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, RenderLaye return operation; } -int ImageNode::getPassIndex(const CompositorContext &context, ListBase *passes, ListBase *views, int passindex, int view_ui) const -{ - if (BLI_countlist(views) < 2) - return passindex; - - const RenderData *rd= context.getRenderData(); - int actview = context.getViewId(); - - bool is_multiview = (view_ui == 0); /* if view selected == All (0) */ - RenderView *rv; - const char *view = NULL; - - if (! is_multiview) { - rv = (RenderView *)BLI_findlink(views, view_ui - 1); - view = rv->name; - } - else { - /* heuristic to match image name with scene names */ - view = this->RenderData_get_actview_name(rd, actview); - - /* this should never happen, but it doesn't hurt to be safe */ - if (view == NULL) - return passindex; - - /* check if the view name exists in the image */ - if(! BLI_findstring(views, view, offsetof(RenderView, name))) - return passindex; - } - - RenderPass *rpass = (RenderPass *)BLI_findlink(passes, passindex); - char passname[64]; - - sprintf(passname, "%s.%s", rpass->internal_name, view); - return BLI_findstringindex(passes, passname, offsetof(RenderPass, name)); -} - void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const { /// Image output @@ -131,39 +95,39 @@ void ImageNode::convertToOperations(NodeConverter &converter, const CompositorCo NodeOperation *operation = NULL; socket = this->getOutputSocket(index); bNodeSocket *bnodeSocket = socket->getbNodeSocket(); - /* Passes in the file can differ from passes stored in sockets (#36755). - * Look up the correct file pass using the socket identifier instead. - */ -#if 0 - NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;*/ - int passindex = getPassIndex(context, &rl->passes, &image->rr->views, storage->pass_index, imageuser->view); - RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex); -#endif - int passindex; - RenderPass *rpass; - for (rpass = (RenderPass *)rl->passes.first, passindex = 0; rpass; rpass = rpass->next, ++passindex) - if (STREQ(rpass->name, bnodeSocket->identifier)) - break; + RenderPass *rpass = (RenderPass*) BLI_findstring(&rl->passes, bnodeSocket->identifier, offsetof(RenderPass, internal_name)); + + int view = (rpass ? rpass->view_id : 0); + /* returns the image view to use for the current active view */ if (BLI_countlist(&image->rr->views) > 1) { - NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage; - passindex = getPassIndex(context, &rl->passes, &image->rr->views, storage->pass_index, imageuser->view); - rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex); + const int view_image = imageuser->view; + const bool is_allview = (view_image == 0); /* if view selected == All (0) */ + + if (is_allview) { + /* heuristic to match image name with scene names */ + const char *view_name = this->RenderData_get_actview_name(context.getRenderData(), context.getViewId()); + + /* check if the view name exists in the image */ + view = BLI_findstringindex(&image->rr->views, view_name, offsetof(RenderView, name)); + } + else { + view = view_image - 1; + } } if (rpass) { - imageuser->pass = passindex; switch (rpass->channels) { case 1: - operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE); + operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VALUE); break; /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */ /* XXX any way to detect actual vector images? */ case 3: - operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR); + operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_VECTOR); break; case 4: - operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR); + operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index, rpass->passtype, view, COM_DT_COLOR); break; default: /* dummy operation is added below */ diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h index d9e6eff..2677945 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.h +++ b/source/blender/compositor/nodes/COM_ImageNode.h @@ -36,8 +36,7 @@ extern "C" { class ImageNode : public Node { private: NodeOperation *doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user, - int framenumber, int outputsocketIndex, int passindex, DataType datatype) const; - int getPassIndex(const CompositorContext &context, struct ListBase *passes, struct ListBase *views, int passindex, int view_id) const; + int framenumber, int outputsocketIndex, int passtype, int view, DataType datatype) const; public: ImageNode(bNode *editorNode); void convertToOperations(NodeConverter &converter, const CompositorContext &context) const; diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp index 23fba5a..6a532f7 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp @@ -27,18 +27,27 @@ extern "C" { # include "IMB_imbuf_types.h" } -MultilayerBaseOperation::MultilayerBaseOperation(int passindex) : BaseImageOperation() +MultilayerBaseOperation::MultilayerBaseOperation(int passtype, int view) : BaseImageOperation() { - this->m_passId = passindex; + this->m_passtype = passtype; + this->m_view = view; } + ImBuf *MultilayerBaseOperation::getImBuf() { - RenderPass *rpass = (RenderPass *)BLI_findlink(&this->m_renderlayer->passes, this->m_passId); - if (rpass) { - this->m_imageUser->pass = m_passId; - BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser); - return BaseImageOperation::getImBuf(); + /* temporarily changes the view to get the right ImBuf */ + int view = this->m_imageUser->view; + + this->m_imageUser->view = this->m_view; + this->m_imageUser->passtype = this->m_passtype; + + if (BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser)) { + ImBuf *ibuf = BaseImageOperation::getImBuf(); + this->m_imageUser->view = view; + return ibuf; } + + this->m_imageUser->view = view; return NULL; } diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs