Fix T60095: freestyle not rendering animated camera correctly.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 24 Jan 2019 15:34:26 +0000 (16:34 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 24 Jan 2019 15:46:11 +0000 (16:46 +0100)
Replace legacy view matrix access with same one used by Eevee.

source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/pipeline.c

index 4d77962bdfa4ec7302fb8de4d1c713947bb58514..14f524199a2301c57599be8f1b8fd9f1e6597835 100644 (file)
@@ -408,9 +408,15 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
        FreestyleEdge *fed = (FreestyleEdge*)CustomData_get_layer(&me->edata, CD_FREESTYLE_EDGE);
        FreestyleFace *ffa = (FreestyleFace*)CustomData_get_layer(&me->pdata, CD_FREESTYLE_FACE);
 
+       // Compute view matrix
+       Object *ob_camera_eval = DEG_get_evaluated_object(_depsgraph, RE_GetCamera(_re));
+       float viewinv[4][4], viewmat[4][4];
+       RE_GetCameraModelMatrix(_re, ob_camera_eval, viewinv);
+       invert_m4_m4(viewmat, viewinv);
+
        // Compute matrix including camera transform
        float obmat[4][4], nmat[4][4];
-       mul_m4_m4m4(obmat, _re->viewmat, ob->obmat);
+       mul_m4_m4m4(obmat, viewmat, ob->obmat);
        invert_m4_m4(nmat, obmat);
        transpose_m4(nmat);
 
index be7bf4f454b511ec46ba5af1c0e38a7ecb950fb4..bde767dc99e27136b401ddbfd4d0457aa9353a1d 100644 (file)
@@ -257,7 +257,6 @@ void RE_SetOrtho(struct Render *re, const rctf *viewplane, float clipsta, float
 void RE_SetView(struct Render *re, float mat[4][4]);
 
 /* get current view and window transform */
-void RE_GetView(struct Render *re, float mat[4][4]);
 void RE_GetViewPlane(struct Render *re, rctf *r_viewplane, rcti *r_disprect);
 
 /* set the render threads based on the commandline and autothreads setting */
index 0f42fff94fe448c33cee10f8e518626e18ad0c1e..e5689dfff74f0f96f267f951dd07699e2824fb11 100644 (file)
@@ -103,8 +103,6 @@ struct Render {
        int partx, party;
 
        /* Camera transform, only used by Freestyle. */
-       float viewmat[4][4], viewinv[4][4];
-       float viewmat_orig[4][4];       /* for incremental render */
        float winmat[4][4];
 
        /* clippping */
index 8b815539d2248b8da35dc0f798f44547dfc18499..6e6bbe6332def0dbabd846edf8f2466e36cc975d 100644 (file)
@@ -966,13 +966,6 @@ void RE_SetOrtho(Render *re, const rctf *viewplane, float clipsta, float clipend
                        re->viewplane.ymin, re->viewplane.ymax, re->clipsta, re->clipend);
 }
 
-void RE_SetView(Render *re, float mat[4][4])
-{
-       /* re->ok flag? */
-       copy_m4_m4(re->viewmat, mat);
-       invert_m4_m4(re->viewinv, re->viewmat);
-}
-
 void RE_GetViewPlane(Render *re, rctf *r_viewplane, rcti *r_disprect)
 {
        *r_viewplane = re->viewplane;
@@ -986,11 +979,6 @@ void RE_GetViewPlane(Render *re, rctf *r_viewplane, rcti *r_disprect)
        }
 }
 
-void RE_GetView(Render *re, float mat[4][4])
-{
-       copy_m4_m4(mat, re->viewmat);
-}
-
 /* image and movie output has to move to either imbuf or kernel */
 void RE_display_init_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr))
 {
@@ -2055,28 +2043,6 @@ void RE_RenderFreestyleExternal(Render *re)
 
                for (rv = re->result->views.first; rv; rv = rv->next) {
                        RE_SetActiveRenderView(re, rv->name);
-
-                       /* scene needs to be set to get camera */
-                       Object *camera = RE_GetCamera(re);
-
-                       /* if no camera, viewmat should have been set! */
-                       if (camera) {
-                               /* called before but need to call again in case of lens animation from the
-                                * above call to BKE_scene_graph_update_for_newframe, fixes bug. [#22702].
-                                * following calls don't depend on 'RE_SetCamera' */
-                               float mat[4][4];
-
-                               RE_SetCamera(re, camera);
-                               RE_GetCameraModelMatrix(re, camera, mat);
-                               invert_m4(mat);
-                               RE_SetView(re, mat);
-
-                               /* force correct matrix for scaled cameras */
-                               DEG_id_tag_update_ex(re->main, &camera->id, ID_RECALC_TRANSFORM);
-                       }
-
-                       printf("add freestyle\n");
-
                        add_freestyle(re, 1);
                }
        }