diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 18:14:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 18:52:48 +0300 |
commit | e053f6b1d8169d54bc3cae058a3caaf72e479d63 (patch) | |
tree | 5ff79193998dc4a9d030b74290bdad406922a981 | |
parent | 8c5c02932f20dac55675448dae4dbccbbc34aaf8 (diff) |
DRW: Copy matrix in case of ModelMatrixInverse being used
ob->imat is garanteed to be valid by the depsgraph.
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 13 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 06b9dedd428..d613203c74d 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -371,12 +371,21 @@ static void drw_call_state_update_matflag(DRWCallState *state, * This is the opposite of what draw_matrices_model_prepare() does. */ state->matflag |= shgroup->matflag; + if (new_flags & DRW_CALL_MODELINVERSE) { + if (ob) { + copy_m4_m4(state->modelinverse, ob->imat); + } + else { + invert_m4_m4(state->modelinverse, state->model); + } + } + /* Orco factors: We compute this at creation to not have to save the *ob_data */ - if ((new_flags & DRW_CALL_ORCOTEXFAC) != 0) { + if (new_flags & DRW_CALL_ORCOTEXFAC) { drw_call_calc_orco(ob, state->orcotexfac); } - if ((new_flags & DRW_CALL_OBJECTINFO) != 0) { + if (new_flags & DRW_CALL_OBJECTINFO) { state->objectinfo[0] = ob ? ob->index : 0; uint random; if (DST.dupli_source) { diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index e29b64c7b1f..823fc7e4091 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -818,10 +818,6 @@ static void draw_matrices_model_prepare(DRWCallState *st) mul_m3_v3(st->normalviewinverse, st->eyevec); } /* Non view dependent */ - if (st->matflag & DRW_CALL_MODELINVERSE) { - invert_m4_m4(st->modelinverse, st->model); - st->matflag &= ~DRW_CALL_MODELINVERSE; - } if (st->matflag & DRW_CALL_NORMALWORLD) { copy_m3_m4(st->normalworld, st->model); invert_m3(st->normalworld); |