[Bf-blender-cvs] [153828b30dc] temp-lineart-contained: LineArt: Move Mesh->BMesh conversion to worker.
YimingWu
noreply at git.blender.org
Mon Jun 7 17:56:57 CEST 2021
Commit: 153828b30dc4968ff249777529a03a49e8d39ca2
Author: YimingWu
Date: Mon Jun 7 21:59:10 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB153828b30dc4968ff249777529a03a49e8d39ca2
LineArt: Move Mesh->BMesh conversion to worker.
===================================================================
M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 56e22a1b308..866f7eb72c5 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -384,7 +384,7 @@ struct BMesh;
typedef struct LineartObjectInfo {
struct LineartObjectInfo *next;
struct Object *original_ob;
- struct BMesh *original_bm;
+ struct Mesh *original_me;
double model_view_proj[4][4];
double model_view[4][4];
double normal[4][4];
@@ -393,8 +393,10 @@ typedef struct LineartObjectInfo {
unsigned char override_intersection_mask;
int global_i_offset;
- /* Threads will add lines inside here, when all threads are done, we combine those into the ones
- * in LineartRenderBuffer. */
+ bool free_use_mesh;
+
+ /* Threads will add lines inside here, when all threads are done, we combine those into the
+ * ones in LineartRenderBuffer. */
ListBase contour;
ListBase intersection;
ListBase crease;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index ed04e5cc06e..3e2427603a1 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1677,7 +1677,27 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
int usage = obi->usage;
- bm = obi->original_bm;
+ if (obi->original_me->edit_mesh) {
+ /* Do not use edit_mesh directly because we will modify it, so create a copy. */
+ bm = BM_mesh_copy(obi->original_me->edit_mesh->bm);
+ }
+ else {
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(((Mesh *)(obi->original_me)));
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+ BM_mesh_bm_from_me(bm,
+ obi->original_me,
+ &((struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+ }
+
+ if (obi->free_use_mesh) {
+ BKE_mesh_free(obi->original_me);
+ MEM_freeN(obi->original_me);
+ }
if (rb->remove_doubles) {
BMEditMesh *em = BKE_editmesh_create(bm, false);
@@ -2109,28 +2129,8 @@ static void lineart_main_load_geometries(
continue;
}
- if (use_mesh->edit_mesh) {
- /* Do not use edit_mesh directly because we will modify it, so create a copy. */
- bm = BM_mesh_copy(use_mesh->edit_mesh->bm);
- }
- else {
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(((Mesh *)(use_mesh)));
- bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = true,
- }));
- BM_mesh_bm_from_me(bm,
- use_mesh,
- &((struct BMeshFromMeshParams){
- .calc_face_normal = true,
- }));
- }
-
- /* We don't need the plain "mesh" data anymore, only BMesh post-processing is done in
- * threads. The workers will free obi->bm */
if (ob->type != OB_MESH) {
- BKE_mesh_free(use_mesh);
- MEM_freeN(use_mesh);
+ obi->free_use_mesh = true;
}
/* Prepare the matrix used for transforming this specific object (instance). */
@@ -2141,9 +2141,9 @@ static void lineart_main_load_geometries(
transpose_m4(imat);
copy_m4d_m4(obi->normal, imat);
- obi->original_bm = bm;
+ obi->original_me = use_mesh;
obi->original_ob = (ob->id.orig_id ? (Object *)ob->id.orig_id : (Object *)ob);
- lineart_geometry_load_assign_thread(olti, obi, thread_count, bm->totface);
+ lineart_geometry_load_assign_thread(olti, obi, thread_count, use_mesh->totpoly);
}
DEG_OBJECT_ITER_END;
More information about the Bf-blender-cvs
mailing list