diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 06:06:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 06:06:33 +0300 |
commit | 6e39aeb2cd805cdc9ddd838b8b27a4287800236b (patch) | |
tree | 85398bceb0a1a36ab7ba4ec66ee79db0d62c4b2a /source/blender/draw | |
parent | a8d11995bfcb16d2ecdfdb196e0ed708d8cf5c36 (diff) |
BMesh: remove BMEditMesh.ob use for draw manager
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 19 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 30 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_text.c | 2 |
4 files changed, 37 insertions, 15 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h index 7ee02c3c556..8c3777a9b1b 100644 --- a/source/blender/draw/intern/draw_cache_extract.h +++ b/source/blender/draw/intern/draw_cache_extract.h @@ -253,6 +253,7 @@ typedef struct MeshBatchCache { void mesh_buffer_cache_create_requested(MeshBatchCache *cache, MeshBufferCache mbc, Mesh *me, + const float obmat[4][4], const bool do_final, const bool do_uvedit, const bool use_subsurf_fdots, diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index 711be9ee776..cce1710423b 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -95,6 +95,9 @@ typedef struct MeshRenderData { bool use_subsurf_fdots; bool use_final_mesh; + /** Use for #MeshStatVis calculation which use world-space coords. */ + float obmat[4][4]; + const ToolSettings *toolsettings; /* HACK not supposed to be there but it's needed. */ struct MeshBatchCache *cache; @@ -125,6 +128,7 @@ typedef struct MeshRenderData { } MeshRenderData; static MeshRenderData *mesh_render_data_create(Mesh *me, + const float obmat[4][4], const bool do_final, const bool do_uvedit, const eMRIterType iter_type, @@ -136,6 +140,8 @@ static MeshRenderData *mesh_render_data_create(Mesh *me, mr->toolsettings = ts; mr->mat_len = mesh_render_mat_len_get(me); + copy_m4_m4(mr->obmat, obmat); + const bool is_auto_smooth = (me->flag & ME_AUTOSMOOTH) != 0; const float split_angle = is_auto_smooth ? me->smoothresh : (float)M_PI; @@ -3102,11 +3108,9 @@ static void statvis_calc_overhang(const MeshRenderData *mr, float *r_overhang) axis_from_enum_v3(dir, axis); - if (em && LIKELY(em->ob)) { - /* now convert into global space */ - mul_transposed_mat3_m4_v3(em->ob->obmat, dir); - normalize_v3(dir); - } + /* now convert into global space */ + mul_transposed_mat3_m4_v3(mr->obmat, dir); + normalize_v3(dir); if (mr->extract_type == MR_EXTRACT_BMESH) { int l = 0; @@ -3164,7 +3168,7 @@ static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness) /* cheating to avoid another allocation */ float *face_dists = r_thickness + (mr->loop_len - mr->poly_len); BMEditMesh *em = mr->edit_bmesh; - const float scale = 1.0f / mat4_to_scale(em->ob->obmat); + const float scale = 1.0f / mat4_to_scale(mr->obmat); const MeshStatVis *statvis = &mr->toolsettings->statvis; const float min = statvis->thickness_min * scale; const float max = statvis->thickness_max * scale; @@ -4374,6 +4378,7 @@ static void extract_task_create(TaskPool *task_pool, void mesh_buffer_cache_create_requested(MeshBatchCache *cache, MeshBufferCache mbc, Mesh *me, + const float obmat[4][4], const bool do_final, const bool do_uvedit, const bool use_subsurf_fdots, @@ -4434,7 +4439,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache, #endif MeshRenderData *mr = mesh_render_data_create( - me, do_final, do_uvedit, iter_flag, data_flag, cd_layer_used, ts); + me, obmat, do_final, do_uvedit, iter_flag, data_flag, cd_layer_used, ts); mr->cache = cache; /* HACK */ mr->use_hide = use_hide; mr->use_subsurf_fdots = use_subsurf_fdots; diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 7c7178eae85..31f4bec7226 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1399,16 +1399,32 @@ void DRW_mesh_batch_cache_create_requested( if (do_uvcage) { mesh_buffer_cache_create_requested( - cache, cache->uv_cage, me, false, true, false, &cache->cd_used, ts, true); + cache, cache->uv_cage, me, ob->obmat, false, true, false, &cache->cd_used, ts, true); } if (do_cage) { - mesh_buffer_cache_create_requested( - cache, cache->cage, me, false, false, use_subsurf_fdots, &cache->cd_used, ts, true); - } - - mesh_buffer_cache_create_requested( - cache, cache->final, me, true, false, use_subsurf_fdots, &cache->cd_used, ts, use_hide); + mesh_buffer_cache_create_requested(cache, + cache->cage, + me, + ob->obmat, + false, + false, + use_subsurf_fdots, + &cache->cd_used, + ts, + true); + } + + mesh_buffer_cache_create_requested(cache, + cache->final, + me, + ob->obmat, + true, + false, + use_subsurf_fdots, + &cache->cd_used, + ts, + use_hide); #ifdef DEBUG check: diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 47fafbdcbd8..92095791ef7 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -253,7 +253,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, BoundBox bb; const rcti rect = {0, ar->winx, 0, ar->winy}; - ED_view3d_clipping_calc(&bb, clip_planes, ar, em->ob, &rect); + ED_view3d_clipping_calc(&bb, clip_planes, ar, ob, &rect); } if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) { |