Multi-View: new util functions RE_RenderViewGetById() and RE_RenderViewGetByName()
authorDalai Felinto <dfelinto@gmail.com>
Wed, 29 Apr 2015 14:18:18 +0000 (11:18 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 29 Apr 2015 14:18:22 +0000 (11:18 -0300)
Both functions try to find a valid RenderView and if they can't they
fallback to the first RenderView of the RenderResult

source/blender/compositor/operations/COM_CompositorOperation.cpp
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/render_result.c

index eacbdf91be2f36170074fed0d2a274efb6897312..76f74c144f6bc88dbb40b976f4feebc75eb8efdf 100644 (file)
@@ -82,7 +82,7 @@ void CompositorOperation::deinitExecution()
                RenderResult *rr = RE_AcquireResultWrite(re);
 
                if (rr) {
-                       RenderView *rv = (RenderView *)BLI_findstring(&rr->views, this->m_viewName, offsetof(RenderView, name));
+                       RenderView *rv = RE_RenderViewGetByName(rr, this->m_viewName);
 
                        if (rv->rectf != NULL) {
                                MEM_freeN(rv->rectf);
index 39e17c281626db036dfd9b8c2b4ff16b57c84269..2c3ad74c7e35683aa18fac7b2be2b691ce0e4d63 100644 (file)
@@ -354,6 +354,8 @@ bool RE_allow_render_generic_object(struct Object *ob);
 bool RE_HasFakeLayer(RenderResult *res);
 bool RE_RenderResult_is_stereo(RenderResult *res);
 
+struct RenderView *RE_RenderViewGetById(struct RenderResult *res, const int view_id);
+struct RenderView *RE_RenderViewGetByName(struct RenderResult *res, const char *viewname);
 float *RE_RenderViewGetRectf(struct RenderResult *rr, const int view_id);
 float *RE_RenderViewGetRectz(struct RenderResult *rr, const int view_id);
 int   *RE_RenderViewGetRect32(struct RenderResult *rr, const int view_id);
index 7206c21de9e9f2ac8f0c95310bc3bcdb918a53e5..c26a74f18c51b1c362d9f0475a7cf8c38c924c65 100644 (file)
@@ -395,9 +395,7 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
                        rr->recty = re->result->recty;
                        
                        /* actview view */
-                       rv = BLI_findlink(&re->result->views, view_id);
-                       if (rv == NULL)
-                               rv = (RenderView *)re->result->views.first;
+                       rv = RE_RenderViewGetById(re->result, view_id);
 
                        rr->rectf =  rv ? rv->rectf  : NULL;
                        rr->rectz =  rv ? rv->rectz  : NULL;
@@ -2287,7 +2285,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
 
                /* store the final result */
                BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
-               rv = BLI_findlink(&re->result->views, nr);
+               rv = RE_RenderViewGetById(re->result, nr);
                if (rv->rectf)
                        MEM_freeN(rv->rectf);
                rv->rectf = rectf;
@@ -2571,7 +2569,7 @@ static void do_render_seq(Render *re)
        BLI_rw_mutex_unlock(&re->resultmutex);
 
        for (view_id = 0; view_id < tot_views; view_id++) {
-               RenderView *rv = BLI_findlink(&rr->views, view_id);
+               RenderView *rv = RE_RenderViewGetById(rr, view_id);
                BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
 
                if (ibuf_arr[view_id]) {
index f3a8dfde299fc2767ff004f4e2f339e6127574b6..1668b11bd2047a5aac13c59d52119b7070472b5c 100644 (file)
@@ -1507,7 +1507,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int vi
 
 void render_result_rect_from_ibuf(RenderResult *rr, RenderData *UNUSED(rd), ImBuf *ibuf, const int view_id)
 {
-       RenderView *rv = BLI_findlink(&rr->views, view_id);
+       RenderView *rv = RE_RenderViewGetById(rr, view_id);
 
        if (ibuf->rect_float) {
                if (!rv->rectf)
@@ -1536,7 +1536,7 @@ void render_result_rect_from_ibuf(RenderResult *rr, RenderData *UNUSED(rd), ImBu
 
 void render_result_rect_fill_zero(RenderResult *rr, const int view_id)
 {
-       RenderView *rv = BLI_findlink(&rr->views, view_id);
+       RenderView *rv = RE_RenderViewGetById(rr, view_id);
 
        if (rv->rectf)
                memset(rv->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty);
@@ -1592,6 +1592,18 @@ bool RE_RenderResult_is_stereo(RenderResult *res)
        return true;
 }
 
+RenderView *RE_RenderViewGetById(RenderResult *res, const int view_id)
+{
+       RenderView *rv = BLI_findlink(&res->views, view_id);
+       return rv ? rv : res->views.first;
+}
+
+RenderView *RE_RenderViewGetByName(RenderResult *res, const char *viewname)
+{
+       RenderView *rv = BLI_findstring(&res->views, viewname, offsetof(RenderView, name));
+       return rv ? rv : res->views.first;
+}
+
 void RE_RenderViewSetRectf(RenderResult *res, const int view_id, float *rect)
 {
        RenderView *rv = BLI_findlink(&res->views, view_id);