[Bf-blender-cvs] [eca95d35bac] blender-v3.3-release: Fix T102612: Line art crash on loading due to references to other scenes.
Commit: eca95d35bacc5858c01c2f3294b429577461c29a Author: YimingWu Date: Thu Jan 5 12:43:05 2023 +0800 Branches: blender-v3.3-release https://developer.blender.org/rBeca95d35bacc5858c01c2f3294b429577461c29a Fix T102612: Line art crash on loading due to references to other scenes. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 8d75082d63f..b0818b157bb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2484,9 +2484,10 @@ static void lineart_object_load_single_instance(LineartData *ld, } if (ob->type == OB_MESH) { use_mesh = BKE_object_get_evaluated_mesh(ob); -if (use_mesh->edit_mesh) { +if ((!use_mesh) || use_mesh->edit_mesh) { /* If the object is being edited, then the mesh is not evaluated fully into the final - * result, do not load them. */ + * result, do not load them. This could be caused by incorrect evaluation order due to + * the way line art uses depsgraph.See T102612 for explaination of this workaround. */ return; } } @@ -2494,7 +2495,7 @@ static void lineart_object_load_single_instance(LineartData *ld, use_mesh = BKE_mesh_new_from_object(depsgraph, ob, true, true); } - /* In case we still can not get any mesh geometry data from the object */ + /* In case we still can not get any mesh geometry data from the object, same as above. */ if (!use_mesh) { return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9d3d9019abd] blender-v3.3-release: Fix T101824: Line art flickers when light object has scaling.
Commit: 9d3d9019abd2f9c8843ceb369f13240dad514cfe Author: YimingWu Date: Thu Jan 12 13:36:05 2023 +0100 Branches: blender-v3.3-release https://developer.blender.org/rB9d3d9019abd2f9c8843ceb369f13240dad514cfe Fix T101824: Line art flickers when light object has scaling. Line art doesn't expect light or camera objects to have scaling. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e251292fe2f..8d75082d63f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3573,6 +3573,10 @@ static LineartData *lineart_create_render_buffer(Scene *scene, copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->obmat[3]); } copy_m4_m4(ld->conf.cam_obmat, camera->obmat); + /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ + normalize_v3(ld->conf.cam_obmat[0]); + normalize_v3(ld->conf.cam_obmat[1]); + normalize_v3(ld->conf.cam_obmat[2]); ld->conf.cam_is_persp = (c->type == CAM_PERSP); ld->conf.near_clip = c->clip_start + clipping_offset; @@ -3601,6 +3605,10 @@ static LineartData *lineart_create_render_buffer(Scene *scene, Object *light_obj = lmd->light_contour_object; copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->obmat[3]); copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->obmat); +/* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ +normalize_v3(ld->conf.cam_obmat_secondary[0]); +normalize_v3(ld->conf.cam_obmat_secondary[1]); +normalize_v3(ld->conf.cam_obmat_secondary[2]); ld->conf.light_reference_available = true; if (light_obj->type == OB_LAMP) { ld->conf.cam_is_persp_secondary = ((Light *)light_obj->data)->type != LA_SUN; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [93fc352cfaf] master: Fix T102612: Line art crash on loading due to references to other scenes.
Commit: 93fc352cfaf0a38bd59d8bfb44c75bf5835ba3dd Author: YimingWu Date: Thu Jan 5 12:43:05 2023 +0800 Branches: master https://developer.blender.org/rB93fc352cfaf0a38bd59d8bfb44c75bf5835ba3dd Fix T102612: Line art crash on loading due to references to other scenes. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc index 1ae91ab29c2..93c1571c613 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc @@ -2450,9 +2450,10 @@ static void lineart_object_load_single_instance(LineartData *ld, } if (ob->type == OB_MESH) { use_mesh = BKE_object_get_evaluated_mesh(ob); -if (use_mesh->edit_mesh) { +if ((!use_mesh) || use_mesh->edit_mesh) { /* If the object is being edited, then the mesh is not evaluated fully into the final - * result, do not load them. */ + * result, do not load them. This could be caused by incorrect evaluation order due to + * the way line art uses depsgraph.See T102612 for explaination of this workaround. */ return; } } @@ -2460,7 +2461,7 @@ static void lineart_object_load_single_instance(LineartData *ld, use_mesh = BKE_mesh_new_from_object(depsgraph, ob, true, true); } - /* In case we still can not get any mesh geometry data from the object */ + /* In case we still can not get any mesh geometry data from the object, same as above. */ if (!use_mesh) { return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [168091a1d63] master: Cleanup: Missing debug #ifdef for GPU_vertbuf_raw_step
Commit: 168091a1d634092c38cd51b6df8f2696c0956812 Author: YimingWu Date: Thu Jan 5 11:01:32 2023 +0800 Branches: master https://developer.blender.org/rB168091a1d634092c38cd51b6df8f2696c0956812 Cleanup: Missing debug #ifdef for GPU_vertbuf_raw_step === M release/datafiles/locale M release/scripts/addons M release/scripts/addons_contrib M source/blender/gpu/GPU_vertex_buffer.h M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 4a581c54af9..7084c4ecd97 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e +Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df diff --git a/release/scripts/addons b/release/scripts/addons index 0b0052bd53a..a9d4443c244 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde +Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 96143b1a8b0..bdcfdd47ec3 16 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3 +Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index d3c1bd8145d..979b7cc06cf 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -141,7 +141,9 @@ GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a) { unsigned char *data = a->data; a->data += a->stride; +#ifdef DEBUG BLI_assert(data < a->_data_end); +#endif return (void *)data; } diff --git a/source/tools b/source/tools index fdfa2fcb949..e1744b9bd82 16 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit fdfa2fcb9495d87571f2dfe2ae9fa0e032536600 +Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2a78941d2cd] blender-v3.3-release: LineArt: Fix "No intersection" flicker.
Commit: 2a78941d2cd0d679b70a1bb1f438d17ebf71ce8a Author: YimingWu Date: Wed Oct 5 18:06:21 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rB2a78941d2cd0d679b70a1bb1f438d17ebf71ce8a LineArt: Fix "No intersection" flicker. The flicker was caused by the failure for checking both triangles for flags. Now fixed. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 5893df2ba56..e251292fe2f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3400,8 +3400,8 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, } tt->testing_e[th->thread_id] = (LineartEdge *)tri; -if(!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)){ - if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || +if (!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)) { + if (((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_NO_INTERSECTION) || (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { continue; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6d879601b76] master: LineArt: Fix "No intersection" flicker.
Commit: 6d879601b76fddde010083b7e59705cfa2955c5e Author: YimingWu Date: Wed Oct 5 18:06:21 2022 +0800 Branches: master https://developer.blender.org/rB6d879601b76fddde010083b7e59705cfa2955c5e LineArt: Fix "No intersection" flicker. The flicker was caused by the failure for checking both triangles for flags. Now fixed. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 305bf62bed3..b0e00fa71fb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3425,7 +3425,7 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, tt->testing_e[th->thread_id] = (LineartEdge *)tri; if (!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)) { - if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || + if (((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_NO_INTERSECTION) || (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { continue; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c1f2cd4871c] blender-v3.3-release: LineArt: Force intersection option.
Commit: c1f2cd4871c73b0419806c124f5b78f9c3fa10cf Author: YimingWu Date: Thu Sep 15 22:02:14 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rBc1f2cd4871c73b0419806c124f5b78f9c3fa10cf LineArt: Force intersection option. This option allows easier setup of intersection overrides on more complex scene structures. Setting force intersection would allow objects to always produce intersection lines even against no-intersection ones. Reviewed By: Aleš Jelovčan (frogstomp) Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15978 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_collection_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesrna/intern/rna_collection.c M source/blender/makesrna/intern/rna_object.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 895ffcc7818..f27efd978ad 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -441,6 +441,7 @@ typedef enum eLineartTriangleFlags { LRT_TRIANGLE_INTERSECTION_ONLY = (1 << 3), LRT_TRIANGLE_NO_INTERSECTION = (1 << 4), LRT_TRIANGLE_MAT_BACK_FACE_CULLING = (1 << 5), + LRT_TRIANGLE_FORCE_INTERSECTION = (1 << 6), } eLineartTriangleFlags; #define LRT_SHADOW_MASK_UNDEFINED 0 diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index d0b1efa183d..5893df2ba56 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1897,6 +1897,9 @@ static void lineart_load_tri_task(void *__restrict userdata, if (ob_info->usage == OBJECT_LRT_INTERSECTION_ONLY) { tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY; } + else if (ob_info->usage == OBJECT_LRT_FORCE_INTERSECTION) { +tri->flags |= LRT_TRIANGLE_FORCE_INTERSECTION; + } else if (ob_info->usage == OBJECT_LRT_NO_INTERSECTION || ob_info->usage == OBJECT_LRT_OCCLUSION_ONLY) { tri->flags |= LRT_TRIANGLE_NO_INTERSECTION; @@ -2238,7 +2241,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, } if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); } @@ -2266,7 +2269,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, la_edge->edge_identifier = LRT_EDGE_IDENTIFIER(ob_info, la_edge); BLI_addtail(_edge->segments, la_seg); if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); if (shadow_eln) { LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, la_edge->edge_identifier); @@ -2367,6 +2370,8 @@ static int lineart_usage_check(Collection *c, Object *ob, bool is_render) return OBJECT_LRT_INTERSECTION_ONLY; case COLLECTION_LRT_NO_INTERSECTION: return OBJECT_LRT_NO_INTERSECTION; + case COLLECTION_LRT_FORCE_INTERSECTION: +return OBJECT_LRT_FORCE_INTERSECTION; } return OBJECT_LRT_INHERIT; } @@ -3395,10 +3400,11 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, } tt->testing_e[th->thread_id] = (LineartEdge *)tri; -if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || -((testing_triangle->flags & LRT_TRIANGLE_INTERSECTION_ONLY) && - (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) { - continue; +if(!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)){ + if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || + (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { +continue; + } } double *RG0 = testing_triangle->v[0]->gloc, *RG1 = testing_triangle->v[1]->gloc, @@ -4521,14 +4527,8 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line _dir_control++;
[Bf-blender-cvs] [78cdd02ab50] temp-T97352-3d-texturing-seam-bleeding-b2: LineArt: Force intersection option.
Commit: 78cdd02ab50d6c52ae1823bd9284f9110c156976 Author: YimingWu Date: Thu Sep 15 22:02:14 2022 +0800 Branches: temp-T97352-3d-texturing-seam-bleeding-b2 https://developer.blender.org/rB78cdd02ab50d6c52ae1823bd9284f9110c156976 LineArt: Force intersection option. This option allows easier setup of intersection overrides on more complex scene structures. Setting force intersection would allow objects to always produce intersection lines even against no-intersection ones. Reviewed By: Aleš Jelovčan (frogstomp) Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15978 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_collection_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesrna/intern/rna_collection.c M source/blender/makesrna/intern/rna_object.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index ae013a7dd02..22037d10a71 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -442,6 +442,7 @@ typedef enum eLineartTriangleFlags { LRT_TRIANGLE_INTERSECTION_ONLY = (1 << 3), LRT_TRIANGLE_NO_INTERSECTION = (1 << 4), LRT_TRIANGLE_MAT_BACK_FACE_CULLING = (1 << 5), + LRT_TRIANGLE_FORCE_INTERSECTION = (1 << 6), } eLineartTriangleFlags; #define LRT_SHADOW_MASK_UNDEFINED 0 diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c4a235d06bc..6d0ede03680 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1905,6 +1905,9 @@ static void lineart_load_tri_task(void *__restrict userdata, if (ob_info->usage == OBJECT_LRT_INTERSECTION_ONLY) { tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY; } + else if (ob_info->usage == OBJECT_LRT_FORCE_INTERSECTION) { +tri->flags |= LRT_TRIANGLE_FORCE_INTERSECTION; + } else if (ob_info->usage == OBJECT_LRT_NO_INTERSECTION || ob_info->usage == OBJECT_LRT_OCCLUSION_ONLY) { tri->flags |= LRT_TRIANGLE_NO_INTERSECTION; @@ -2252,7 +2255,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, } if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); } @@ -2281,7 +2284,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, la_edge->edge_identifier = LRT_EDGE_IDENTIFIER(ob_info, la_edge); BLI_addtail(_edge->segments, la_seg); if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); if (shadow_eln) { LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, la_edge->edge_identifier); @@ -2382,6 +2385,8 @@ static int lineart_usage_check(Collection *c, Object *ob, bool is_render) return OBJECT_LRT_INTERSECTION_ONLY; case COLLECTION_LRT_NO_INTERSECTION: return OBJECT_LRT_NO_INTERSECTION; + case COLLECTION_LRT_FORCE_INTERSECTION: +return OBJECT_LRT_FORCE_INTERSECTION; } return OBJECT_LRT_INHERIT; } @@ -3410,10 +3415,11 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, } tt->testing_e[th->thread_id] = (LineartEdge *)tri; -if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || -((testing_triangle->flags & LRT_TRIANGLE_INTERSECTION_ONLY) && - (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) { - continue; +if(!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)){ + if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || + (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { +continue; + } } double *RG0 = testing_triangle->v[0]->gloc, *RG1 = testing_triangle->v[1]->gloc, @@ -4535,14 +4541,8 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line _dir_control++;
[Bf-blender-cvs] [0bdb5239c1a] master: LineArt: Force intersection option.
Commit: 0bdb5239c1a55e72adf3d3d7c491df3d86cd0b09 Author: YimingWu Date: Thu Sep 15 22:02:14 2022 +0800 Branches: master https://developer.blender.org/rB0bdb5239c1a55e72adf3d3d7c491df3d86cd0b09 LineArt: Force intersection option. This option allows easier setup of intersection overrides on more complex scene structures. Setting force intersection would allow objects to always produce intersection lines even against no-intersection ones. Reviewed By: Aleš Jelovčan (frogstomp) Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15978 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_collection_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesrna/intern/rna_collection.c M source/blender/makesrna/intern/rna_object.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index ae013a7dd02..22037d10a71 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -442,6 +442,7 @@ typedef enum eLineartTriangleFlags { LRT_TRIANGLE_INTERSECTION_ONLY = (1 << 3), LRT_TRIANGLE_NO_INTERSECTION = (1 << 4), LRT_TRIANGLE_MAT_BACK_FACE_CULLING = (1 << 5), + LRT_TRIANGLE_FORCE_INTERSECTION = (1 << 6), } eLineartTriangleFlags; #define LRT_SHADOW_MASK_UNDEFINED 0 diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c4a235d06bc..6d0ede03680 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1905,6 +1905,9 @@ static void lineart_load_tri_task(void *__restrict userdata, if (ob_info->usage == OBJECT_LRT_INTERSECTION_ONLY) { tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY; } + else if (ob_info->usage == OBJECT_LRT_FORCE_INTERSECTION) { +tri->flags |= LRT_TRIANGLE_FORCE_INTERSECTION; + } else if (ob_info->usage == OBJECT_LRT_NO_INTERSECTION || ob_info->usage == OBJECT_LRT_OCCLUSION_ONLY) { tri->flags |= LRT_TRIANGLE_NO_INTERSECTION; @@ -2252,7 +2255,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, } if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); } @@ -2281,7 +2284,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, la_edge->edge_identifier = LRT_EDGE_IDENTIFIER(ob_info, la_edge); BLI_addtail(_edge->segments, la_seg); if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); if (shadow_eln) { LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, la_edge->edge_identifier); @@ -2382,6 +2385,8 @@ static int lineart_usage_check(Collection *c, Object *ob, bool is_render) return OBJECT_LRT_INTERSECTION_ONLY; case COLLECTION_LRT_NO_INTERSECTION: return OBJECT_LRT_NO_INTERSECTION; + case COLLECTION_LRT_FORCE_INTERSECTION: +return OBJECT_LRT_FORCE_INTERSECTION; } return OBJECT_LRT_INHERIT; } @@ -3410,10 +3415,11 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, } tt->testing_e[th->thread_id] = (LineartEdge *)tri; -if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || -((testing_triangle->flags & LRT_TRIANGLE_INTERSECTION_ONLY) && - (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) { - continue; +if(!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)){ + if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) || + (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { +continue; + } } double *RG0 = testing_triangle->v[0]->gloc, *RG1 = testing_triangle->v[1]->gloc, @@ -4535,14 +4541,8 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line _dir_control++; for (co = x1; co <= x2; co++) { for (r = y1; r <= y2
[Bf-blender-cvs] [dc733cf17de] master: Merge branch 'blender-v3.3-release'
Commit: dc733cf17de4095e35a879a70b01bcd67c512167 Author: YimingWu Date: Wed Aug 31 10:02:45 2022 +0800 Branches: master https://developer.blender.org/rBdc733cf17de4095e35a879a70b01bcd67c512167 Merge branch 'blender-v3.3-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [66fecfcda6f] blender-v3.3-release: LineArt: Fix (unreported) wrong index in weight transfer
Commit: 66fecfcda6f5e0dacf3d86091e08292e8624c895 Author: YimingWu Date: Thu Aug 18 20:46:04 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rB66fecfcda6f5e0dacf3d86091e08292e8624c895 LineArt: Fix (unreported) wrong index in weight transfer Line art now uses global index for vertices but needs to have local index in order to do correct weight transfer. === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 8d34fb2ffb2..895ffcc7818 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -84,6 +84,7 @@ typedef struct LineartElementLinkNode { /* For edge element link nodes, used for shadow edge matching. */ int obindex; + int global_index_offset; /** Per object value, always set, if not enabled by #ObjectLineArt, then it's set to global. */ float crease_threshold; @@ -205,6 +206,10 @@ typedef struct LineartEdgeChain { uint8_t intersection_mask; uint32_t shadow_mask_bits; + /* We need local index for correct weight transfer, line art index is global, thus + * local_index=lineart_index-index_offset. */ + uint32_t index_offset; + struct Object *object_ref; struct Object *silhouette_backdrop; } LineartEdgeChain; @@ -864,6 +869,7 @@ void MOD_lineart_chain_find_silhouette_backdrop_objects(LineartData *ld); int MOD_lineart_chain_count(const LineartEdgeChain *ec); void MOD_lineart_chain_clear_picked_flag(LineartCache *lc); +void MOD_lineart_finalize_chains(LineartData *ld); /** * This is the entry point of all line art calculations. diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 7c8e0c5a6f5..f32141a31eb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -1051,6 +1051,38 @@ void MOD_lineart_chain_clear_picked_flag(LineartCache *lc) } } +LineartElementLinkNode *lineart_find_matching_eln_obj(ListBase *elns, struct Object *obj) +{ + LISTBASE_FOREACH (LineartElementLinkNode *, eln, elns) { +if (eln->object_ref == obj) { + return eln; +} + } + return NULL; +} + +void MOD_lineart_finalize_chains(LineartData *ld) +{ + LISTBASE_FOREACH (LineartEdgeChain *, ec, >chains) { +if (ELEM(ec->type, + LRT_EDGE_FLAG_INTERSECTION, + LRT_EDGE_FLAG_PROJECTED_SHADOW, + LRT_EDGE_FLAG_LIGHT_CONTOUR)) { + continue; +} +LineartElementLinkNode *eln = lineart_find_matching_eln_obj(>geom.vertex_buffer_pointers, + ec->object_ref); +BLI_assert(eln != NULL); +if (LIKELY(eln)) { + LISTBASE_FOREACH (LineartEdgeChainItem *, eci, >chain) { +if (eci->index > eln->global_index_offset) { + eci->index -= eln->global_index_offset; +} + } +} + } +} + void MOD_lineart_smooth_chains(LineartData *ld, float tolerance) { LISTBASE_FOREACH (LineartEdgeChain *, ec, >chains) { diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 2bc59d318c7..d0b1efa183d 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2651,6 +2651,7 @@ void lineart_main_load_geometries(Depsgraph *depsgraph, } LineartVert *v = (LineartVert *)obi->v_eln->pointer; int v_count = obi->v_eln->element_count; + obi->v_eln->global_index_offset = global_i; for (int vi = 0; vi < v_count; vi++) { v[vi].index += global_i; } @@ -5106,6 +5107,8 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, /* At last, we need to clear flags so we don't confuse GPencil generation calls. */ MOD_lineart_chain_clear_picked_flag(lc); + +MOD_lineart_finalize_chains(ld); } lineart_mem_destroy(>shadow_data_pool); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h index 3668f1dc6d7..947586aaec4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h @@ -133,6
[Bf-blender-cvs] [fec90a5d589] blender-v3.3-release: GPencil: Fix sharp_threshold property in sample stroke operator
Commit: fec90a5d589e334ad4c11f3756dcd8ffd1f94666 Author: YimingWu Date: Wed Aug 31 10:00:35 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rBfec90a5d589e334ad4c11f3756dcd8ffd1f94666 GPencil: Fix sharp_threshold property in sample stroke operator The property registration was missing in the operator, now fixed. === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c05ab8c6b28..e6ab6d061ea 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -4483,6 +4483,7 @@ void GPENCIL_OT_stroke_sample(wmOperatorType *ot) /* properties */ prop = RNA_def_float(ot->srna, "length", 0.1f, 0.0f, 100.0f, "Length", "", 0.0f, 100.0f); + prop = RNA_def_float(ot->srna, "sharp_threshold", 0.1f, 0.0f, M_PI, "Sharp Threshold", "", 0.0f, M_PI); /* avoid re-using last var */ RNA_def_property_flag(prop, PROP_SKIP_SAVE); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7bfd78d450e] master: Merge branch 'blender-v3.3-release'
Commit: 7bfd78d450ef86e44ded0d1134a990d4ad63ec25 Author: YimingWu Date: Tue Aug 16 18:33:23 2022 +0800 Branches: master https://developer.blender.org/rB7bfd78d450ef86e44ded0d1134a990d4ad63ec25 Merge branch 'blender-v3.3-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [accf38c1d1d] blender-v3.3-release: Fix T100435: Use evaluated material for line art loading.
Commit: accf38c1d1d9c2b34f8e30ee1f1cbbf3cdfb69f6 Author: YimingWu Date: Tue Aug 16 18:29:54 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rBaccf38c1d1d9c2b34f8e30ee1f1cbbf3cdfb69f6 Fix T100435: Use evaluated material for line art loading. Materials can be changed by other evaluations like geometry nodes, now handles that kind of situation. === 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 224146d0032..8d34fb2ffb2 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -482,6 +482,7 @@ typedef struct LineartRenderTaskInfo { typedef struct LineartObjectInfo { struct LineartObjectInfo *next; struct Object *original_ob; + struct Object *original_ob_eval; /* For evaluated materials */ struct Mesh *original_me; double model_view_proj[4][4]; double model_view[4][4]; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index a6b9f1420f1..f966af088c1 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1471,6 +1471,7 @@ typedef struct EdgeFeatData { LineartData *ld; Mesh *me; Object *ob; + Object *ob_eval; /* For evaluated materials. */ const MLoopTri *mlooptri; LineartTriangle *tri_array; LineartVert *v_array; @@ -1504,6 +1505,7 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk; Mesh *me = e_feat_data->me; Object *ob = e_feat_data->ob; + Object *ob_eval = e_feat_data->ob_eval; LineartEdgeNeighbor *edge_nabr = e_feat_data->edge_nabr; const MLoopTri *mlooptri = e_feat_data->mlooptri; @@ -1653,8 +1655,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, int mat2 = me->mpoly[mlooptri[f2].poly].mat_nr; if (mat1 != mat2) { - Material *m1 = BKE_object_material_get(ob, mat1 + 1); - Material *m2 = BKE_object_material_get(ob, mat2 + 1); + Material *m1 = BKE_object_material_get_eval(ob_eval, mat1 + 1); + Material *m2 = BKE_object_material_get_eval(ob_eval, mat2 + 1); if (m1 && m2 && ((m1->lineart.mat_occlusion == 0 && m2->lineart.mat_occlusion != 0) || (m2->lineart.mat_occlusion == 0 && m1->lineart.mat_occlusion != 0))) { @@ -1869,8 +1871,8 @@ static void lineart_load_tri_task(void *__restrict userdata, tri->v[2] = _arr[v3]; /* Material mask bits and occlusion effectiveness assignment. */ - Material *mat = BKE_object_material_get(ob_info->original_ob, - me->mpoly[mlooptri->poly].mat_nr + 1); + Material *mat = BKE_object_material_get_eval(ob_info->original_ob_eval, + me->mpoly[mlooptri->poly].mat_nr + 1); tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ? mat->lineart.material_mask_bits : 0); @@ -2121,6 +2123,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, edge_feat_data.ld = la_data; edge_feat_data.me = me; edge_feat_data.ob = orig_ob; + edge_feat_data.ob_eval = ob_info->original_ob_eval; edge_feat_data.mlooptri = mlooptri; edge_feat_data.edge_nabr = lineart_build_edge_neighbor(me, total_edges); edge_feat_data.tri_array = la_tri_arr; @@ -2511,6 +2514,7 @@ static void lineart_object_load_single_instance(LineartData *ld, obi->original_me = use_mesh; obi->original_ob = (ref_ob->id.orig_id ? (Object *)ref_ob->id.orig_id : (Object *)ref_ob); + obi->original_ob_eval = DEG_get_evaluated_object(depsgraph, obi->original_ob); lineart_geometry_load_assign_thread(olti, obi, thread_count, use_mesh->totpoly); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [498e26fa0f6] blender-v3.3-release: Fix T100138: Use `double` for LineArt intersection record.
Commit: 498e26fa0f6486fa2d3bb0029b11eb1dc48a32be Author: YimingWu Date: Fri Aug 12 15:38:26 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rB498e26fa0f6486fa2d3bb0029b11eb1dc48a32be Fix T100138: Use `double` for LineArt intersection record. The use of `float` for intermediate intersection record led to some inaccuracy which caused flickering in intersection lines. Now fixed. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 011c79025c4..9970e4d5ac1 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -50,7 +50,7 @@ #include "lineart_intern.h" typedef struct LineartIsecSingle { - float v1[3], v2[3]; + double v1[3], v2[3]; LineartTriangle *tri1, *tri2; } LineartIsecSingle; @@ -3285,8 +3285,8 @@ static void lineart_add_isec_thread(LineartIsecThread *th, th->array = new_array; } LineartIsecSingle *isec_single = >array[th->current]; - copy_v3fl_v3db(isec_single->v1, v1); - copy_v3fl_v3db(isec_single->v2, v2); + copy_v3_v3_db(isec_single->v1, v1); + copy_v3_v3_db(isec_single->v2, v2); isec_single->tri1 = tri1; isec_single->tri2 = tri2; if (tri1->target_reference > tri2->target_reference) { @@ -4582,8 +4582,8 @@ static void lineart_create_edges_from_isec_data(LineartIsecData *d) LineartIsecSingle *is = >array[j]; LineartVert *v1 = v; LineartVert *v2 = v + 1; - copy_v3db_v3fl(v1->gloc, is->v1); - copy_v3db_v3fl(v2->gloc, is->v2); + copy_v3_v3_db(v1->gloc, is->v1); + copy_v3_v3_db(v2->gloc, is->v2); /* The intersection line has been generated only in geometry space, so we need to transform * them as well. */ mul_v4_m4v3_db(v1->fbcoord, ld->conf.view_projection, v1->gloc); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8dadc091d02] blender-v3.3-release: LineArt: Usability improvement for "Enclosed Shapes".
Commit: 8dadc091d02a7a046a73f77757766ef6fdeffda9 Author: YimingWu Date: Sat Aug 6 11:06:34 2022 +0800 Branches: blender-v3.3-release https://developer.blender.org/rB8dadc091d02a7a046a73f77757766ef6fdeffda9 LineArt: Usability improvement for "Enclosed Shapes". This patch removes the [rather confusing] separate checkbox for enclosed shapes in favour of integrating that option into illumination filtering, with the benefit of not limiting the selection to cached result. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D15327 === M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c M source/blender/makesdna/DNA_gpencil_modifier_types.h M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 77616ae13b6..6bb59f29b98 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -373,19 +373,16 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel) } sub = uiLayoutRow(col, false); - uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE); - entry = uiLayoutColumn(sub, false); - uiItemL(entry, IFACE_("Crease"), ICON_NONE); - uiLayoutSetActive(entry, RNA_boolean_get(ptr, "use_crease") || is_first); if (use_cache && !is_first) { -uiItemL(entry, IFACE_("Crease Angle Cached"), ICON_INFO); +uiItemR(sub, ptr, "use_crease", 0, IFACE_("Crease (Angle Cached)"), ICON_NONE); } else { -uiItemR(entry, +uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE); +uiItemR(sub, ptr, "crease_threshold", UI_ITEM_R_SLIDER | UI_ITEM_R_FORCE_BLANK_DECORATE, -IFACE_("Default Angle"), +NULL, ICON_NONE); } @@ -447,8 +444,6 @@ static void options_light_reference_draw(const bContext *UNUSED(C), Panel *panel uiLayout *col = uiLayoutColumn(remaining, true); uiItemR(col, ptr, "shadow_camera_near", 0, "Near", ICON_NONE); uiItemR(col, ptr, "shadow_camera_far", 0, "Far", ICON_NONE); - - uiItemR(layout, ptr, "use_shadow_enclosed_shapes", 0, IFACE_("Enclosed Shapes"), ICON_NONE); } static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 5dd833fb12b..224146d0032 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -439,12 +439,17 @@ typedef enum eLineartTriangleFlags { } eLineartTriangleFlags; #define LRT_SHADOW_MASK_UNDEFINED 0 -#define LRT_SHADOW_MASK_LIT (1 << 0) +#define LRT_SHADOW_MASK_ILLUMINATED (1 << 0) #define LRT_SHADOW_MASK_SHADED (1 << 1) #define LRT_SHADOW_MASK_ENCLOSED_SHAPE (1 << 2) #define LRT_SHADOW_MASK_INHIBITED (1 << 3) #define LRT_SHADOW_SILHOUETTE_ERASED_GROUP (1 << 4) #define LRT_SHADOW_SILHOUETTE_ERASED_OBJECT (1 << 5) +#define LRT_SHADOW_MASK_ILLUMINATED_SHAPE (1 << 6) + +#define LRT_SHADOW_TEST_SHAPE_BITS \ + (LRT_SHADOW_MASK_ILLUMINATED | LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_INHIBITED | \ + LRT_SHADOW_MASK_ILLUMINATED_SHAPE) /** * Controls how many edges a worker thread is processing at one request. diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 874da3b88c9..011c79025c4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -304,13 +304,12 @@ void lineart_edge_cut(LineartData *ld, /* The enclosed shape flag will override regular lit/shaded * flags. See LineartEdgeSegment::shadow_mask_bits for details. */ if (shadow_bits == LRT_SHADOW_MASK_ENCLOSED_SHAPE) { - if (seg->shadow_mask_bits & LRT_SHADOW_MASK_LIT || e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { -seg->shadow_mask_bits &= ~LRT_SHADOW_MASK_LIT; + if (seg->shadow_mask_bits & LRT_SHADOW_MASK_ILLUMINATED || + e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) {
[Bf-blender-cvs] [ad148e4fda5] temp-T97352-3d-texturing-seam-bleeding-b2: GPencil: Dot-dash modifier rename segment bug fix.
Commit: ad148e4fda589a67c26584ce3550d3ccacabb5e2 Author: YimingWu Date: Mon Jul 11 10:12:49 2022 +0800 Branches: temp-T97352-3d-texturing-seam-bleeding-b2 https://developer.blender.org/rBad148e4fda589a67c26584ce3550d3ccacabb5e2 GPencil: Dot-dash modifier rename segment bug fix. This patch fixes naming and renaming issue with dot-dash modifier segment list. Before: when double clicking and exiting it would append number at the end regardless of name being changed or not. Now it works like in other areas. Authored by: Aleš Jelovčan (frogstomp) Reviewed By: YimingWu (NicksBest) Differential Revision: https://developer.blender.org/D15359 === M release/scripts/addons M source/blender/makesrna/intern/rna_gpencil_modifier.c M source/tools === diff --git a/release/scripts/addons b/release/scripts/addons index 403b95ef6ff..7ea2e74fc41 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 403b95ef6ff38918de966ed2a5843cfa3274a58b +Subproject commit 7ea2e74fc41b2eabdbf639b812082e73823b09d7 diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index dccf7d7a7a9..d3e1aab1ba0 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -774,7 +774,7 @@ static bool dash_segment_name_exists_fn(void *arg, const char *name) { const DashGpencilModifierData *dmd = (const DashGpencilModifierData *)arg; for (int i = 0; i < dmd->segments_len; i++) { -if (STREQ(dmd->segments[i].name, name)) { +if (STREQ(dmd->segments[i].name, name) && dmd->segments[i].name != name) { return true; } } diff --git a/source/tools b/source/tools index 01b4c0e4a17..da8bdd7244c 16 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 01b4c0e4a172819414229445c314be34527bf412 +Subproject commit da8bdd7244c7b6c2eadf4c949ff391d0cc430275 ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d51bc8215f5] master: GPencil: Dot-dash modifier rename segment bug fix.
Commit: d51bc8215f515144ae51cc5feec01b3dbc7900c4 Author: YimingWu Date: Mon Jul 11 10:12:49 2022 +0800 Branches: master https://developer.blender.org/rBd51bc8215f515144ae51cc5feec01b3dbc7900c4 GPencil: Dot-dash modifier rename segment bug fix. This patch fixes naming and renaming issue with dot-dash modifier segment list. Before: when double clicking and exiting it would append number at the end regardless of name being changed or not. Now it works like in other areas. Authored by: Aleš Jelovčan (frogstomp) Reviewed By: YimingWu (NicksBest) Differential Revision: https://developer.blender.org/D15359 === M release/scripts/addons M source/blender/makesrna/intern/rna_gpencil_modifier.c M source/tools === diff --git a/release/scripts/addons b/release/scripts/addons index 403b95ef6ff..7ea2e74fc41 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 403b95ef6ff38918de966ed2a5843cfa3274a58b +Subproject commit 7ea2e74fc41b2eabdbf639b812082e73823b09d7 diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index dccf7d7a7a9..d3e1aab1ba0 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -774,7 +774,7 @@ static bool dash_segment_name_exists_fn(void *arg, const char *name) { const DashGpencilModifierData *dmd = (const DashGpencilModifierData *)arg; for (int i = 0; i < dmd->segments_len; i++) { -if (STREQ(dmd->segments[i].name, name)) { +if (STREQ(dmd->segments[i].name, name) && dmd->segments[i].name != name) { return true; } } diff --git a/source/tools b/source/tools index 01b4c0e4a17..da8bdd7244c 16 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 01b4c0e4a172819414229445c314be34527bf412 +Subproject commit da8bdd7244c7b6c2eadf4c949ff391d0cc430275 ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [53dc52c83d8] lineart-shadow: LineArt: split shadow functions into separate files.
Commit: 53dc52c83d88652503b78cd1ca3660c197b60d3d Author: YimingWu Date: Tue May 31 19:27:43 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB53dc52c83d88652503b78cd1ca3660c197b60d3d LineArt: split shadow functions into separate files. === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h A source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index c45209661f6..46d1ea2c094 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -69,6 +69,7 @@ set(SRC intern/lineart/lineart_cpp_bridge.cc intern/lineart/lineart_cpu.c intern/lineart/lineart_ops.c + intern/lineart/lineart_shadow.c intern/lineart/lineart_util.c intern/lineart/MOD_lineart.h diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 5e17839e262..38bc230fa7d 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -460,6 +460,13 @@ typedef enum eLineartTriangleFlags { LRT_TRIANGLE_MAT_BACK_FACE_CULLING = (1 << 5), } eLineartTriangleFlags; +#define LRT_SHADOW_MASK_UNDEFINED 0 +#define LRT_SHADOW_MASK_LIT (1 << 0) +#define LRT_SHADOW_MASK_SHADED (1 << 1) +#define LRT_SHADOW_MASK_ENCLOSED_SHAPE (1 << 2) +#define LRT_SHADOW_MASK_INHIBITED (1 << 3) +#define LRT_SHADOW_SILHOUETTE_ERASED (1 << 4) + /** * Controls how many edges a worker thread is processing at one request. * There's no significant performance impact on choosing different values. diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e922a8b9163..df94e285d4c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -85,25 +85,10 @@ typedef struct LineartIsecData { int thread_count; } LineartIsecData; -static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb, - double *fbcoord1, - double *fbcoord2); - static void lineart_bounding_area_link_edge(LineartRenderBuffer *rb, LineartBoundingArea *root_ba, LineartEdge *e); -static LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *this, - double *fbcoord1, - double *fbcoord2, - double x, - double y, - double k, - int positive_x, - int positive_y, - double *next_x, - double *next_y); - static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb, LineartEdge *e, int *rowbegin, @@ -124,8 +109,6 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl, double *from, double *to); -static void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e); - static void lineart_bounding_area_link_triangle_cas(LineartRenderBuffer *rb, LineartBoundingArea *root_ba, LineartTriangle *tri, @@ -141,8 +124,6 @@ static void lineart_free_bounding_area_memories(LineartRenderBuffer *rb); static LineartCache *lineart_init_cache(void); -static void lineart_clear_linked_edges(LineartRenderBuffer *rb); - static void lineart_discard_segment(LineartRenderBuffer *rb, LineartEdgeSegment *es) { BLI_spin_lock(>lock_cuts); @@ -174,23 +155,16 @@ static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb) sizeof(LineartEdgeSegment)); }
[Bf-blender-cvs] [3d66ee8c978] master: Intern/atomic: Fix `const` qualifier for `atomic_load_ptr`.
Commit: 3d66ee8c97898ff676f46e866e4003ac1039b3f6 Author: YimingWu Date: Tue May 31 21:04:32 2022 +0800 Branches: master https://developer.blender.org/rB3d66ee8c97898ff676f46e866e4003ac1039b3f6 Intern/atomic: Fix `const` qualifier for `atomic_load_ptr`. === M intern/atomic/atomic_ops.h M intern/atomic/intern/atomic_ops_ext.h === diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h index d1d672a1c4b..65b0c8f9671 100644 --- a/intern/atomic/atomic_ops.h +++ b/intern/atomic/atomic_ops.h @@ -124,7 +124,7 @@ ATOMIC_INLINE unsigned int atomic_fetch_and_sub_u(unsigned int *p, unsigned int ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsigned int _new); ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new); -ATOMIC_INLINE void *atomic_load_ptr(const void **v); +ATOMIC_INLINE void *atomic_load_ptr(void *const *v); ATOMIC_INLINE void atomic_store_ptr(void **p, void *v); ATOMIC_INLINE float atomic_cas_float(float *v, float old, float _new); diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h index fcf01c942ff..b5e1022fb91 100644 --- a/intern/atomic/intern/atomic_ops_ext.h +++ b/intern/atomic/intern/atomic_ops_ext.h @@ -205,7 +205,7 @@ ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new) #endif } -ATOMIC_INLINE void *atomic_load_ptr(const void **v) +ATOMIC_INLINE void *atomic_load_ptr(void *const *v) { #if (LG_SIZEOF_PTR == 8) return (void *)atomic_load_uint64((const uint64_t *)v); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e37027634bd] master: Intern/atomic: Adding atomic_load/store_ptr support.
Commit: e37027634bd3cb53a8447f2728c87e3fa122b5bb Author: YimingWu Date: Tue May 31 20:08:37 2022 +0800 Branches: master https://developer.blender.org/rBe37027634bd3cb53a8447f2728c87e3fa122b5bb Intern/atomic: Adding atomic_load/store_ptr support. We need to provide _ptr ones with _z ones on the API level. Reviewed By: Sergey Sharybin (sergey) Ref D15076 === M intern/atomic/atomic_ops.h M intern/atomic/intern/atomic_ops_ext.h M intern/atomic/tests/atomic_test.cc === diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h index 2bedce1b4f0..d1d672a1c4b 100644 --- a/intern/atomic/atomic_ops.h +++ b/intern/atomic/atomic_ops.h @@ -124,6 +124,8 @@ ATOMIC_INLINE unsigned int atomic_fetch_and_sub_u(unsigned int *p, unsigned int ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsigned int _new); ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new); +ATOMIC_INLINE void *atomic_load_ptr(const void **v); +ATOMIC_INLINE void atomic_store_ptr(void **p, void *v); ATOMIC_INLINE float atomic_cas_float(float *v, float old, float _new); diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h index 6ecc47f18be..fcf01c942ff 100644 --- a/intern/atomic/intern/atomic_ops_ext.h +++ b/intern/atomic/intern/atomic_ops_ext.h @@ -205,6 +205,24 @@ ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new) #endif } +ATOMIC_INLINE void *atomic_load_ptr(const void **v) +{ +#if (LG_SIZEOF_PTR == 8) + return (void *)atomic_load_uint64((const uint64_t *)v); +#elif (LG_SIZEOF_PTR == 4) + return (void *)atomic_load_uint32((const uint32_t *)v); +#endif +} + +ATOMIC_INLINE void atomic_store_ptr(void **p, void *v) +{ +#if (LG_SIZEOF_PTR == 8) + atomic_store_uint64((uint64_t *)p, (uint64_t)v); +#elif (LG_SIZEOF_PTR == 4) + atomic_store_uint32((uint32_t *)p, (uint32_t)v); +#endif +} + /**/ /* float operations. */ ATOMIC_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "sizeof(float) != sizeof(uint32_t)"); diff --git a/intern/atomic/tests/atomic_test.cc b/intern/atomic/tests/atomic_test.cc index ee06085c95d..37a66cf0e9c 100644 --- a/intern/atomic/tests/atomic_test.cc +++ b/intern/atomic/tests/atomic_test.cc @@ -1060,6 +1060,25 @@ TEST(atomic, atomic_cas_ptr) } } +TEST(atomic, atomic_load_ptr) +{ + { +void *value = INT_AS_PTR(0x7f); +void *dest = atomic_load_ptr(); +EXPECT_EQ(dest, INT_AS_PTR(0x7f)); + } +} + +TEST(atomic, atomic_store_ptr) +{ + { +void *value = INT_AS_PTR(0x7f); +void *dest = nullptr; +atomic_store_ptr(, value); +EXPECT_EQ(dest, INT_AS_PTR(0x7f)); + } +} + #undef INT_AS_PTR /** \} */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [90da8c5f4a8] lineart-shadow: LineArt: Cas
Commit: 90da8c5f4a8e1d8002b6e4d448f80833250289a3 Author: YimingWu Date: Mon May 30 09:49:31 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB90da8c5f4a8e1d8002b6e4d448f80833250289a3 LineArt: Cas === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index f5e2c285230..e2329580594 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3035,7 +3035,7 @@ static LineartVert *lineart_triangle_share_point(const LineartTriangle *l, } static bool lineart_triangle_2v_intersection_math( -LineartVert *v1, LineartVert *v2, LineartTriangle *t2, float *last, float *rv) +LineartVert *v1, LineartVert *v2, LineartTriangle *t2, double *last, double *rv) { double Lv[3]; double Rv[3]; @@ -3069,17 +3069,17 @@ static bool lineart_triangle_2v_intersection_math( return false; } - copy_v3fl_v3db(rv, gloc); + copy_v3_v3_db(rv, gloc); return true; } static bool lineart_triangle_intersect_math(LineartTriangle *tri, LineartTriangle *t2, -float *v1, -float *v2) +double *v1, +double *v2) { - float *next = v1, *last = NULL; + double *next = v1, *last = NULL; LineartVert *sv1, *sv2; LineartVert *share = lineart_triangle_share_point(t2, tri); @@ -3090,7 +3090,7 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri, lineart_triangle_get_other_verts(tri, share, , ); -copy_v3fl_v3db(v1, share->gloc); +copy_v3_v3_db(v1, share->gloc); if (!lineart_triangle_2v_intersection_math(sv1, sv2, t2, 0, v2)) { lineart_triangle_get_other_verts(t2, share, , ); @@ -3148,8 +3148,8 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri, } static void lineart_add_isec_thread(LineartIsecThread *th, -const float *v1, -const float *v2, +const double *v1, +const double *v2, LineartTriangle *tri1, LineartTriangle *tri2) { @@ -3163,14 +3163,14 @@ static void lineart_add_isec_thread(LineartIsecThread *th, th->array = new_array; } LineartIsecSingle *is = >array[th->current]; - copy_v3_v3(is->v1, v1); - copy_v3_v3(is->v2, v2); + copy_v3fl_v3db(is->v1, v1); + copy_v3fl_v3db(is->v2, v2); is->tri1 = tri1; is->tri2 = tri2; th->current++; } -#define LRT_ISECT_TRIANGLE_PER_THREAD 4096; +#define LRT_ISECT_TRIANGLE_PER_THREAD 4096 static bool lineart_schedule_new_triangle_task(LineartIsecThread *th) { @@ -3210,6 +3210,11 @@ static bool lineart_schedule_new_triangle_task(LineartIsecThread *th) return true; } +/* This function initializes two things: + * 1) Triangle array scheduling info, for each worker thread to get it's chunk from the scheduler. + * 2) Per-thread intersection result array. Does not store actual #LineartEdge, these results will + * be finalized by #lineart_create_edges_from_isec_data + */ static void lineart_init_isec_thread(LineartIsecData *d, LineartRenderBuffer *rb, int thread_count) { d->threads = MEM_callocN(sizeof(LineartIsecThread) * thread_count, "LineartIsecThread arr"); @@ -3225,14 +3230,8 @@ static void lineart_init_isec_thread(LineartIsecData *d, LineartRenderBuffer *rb it->max = 100; it->current = 0; it->thread_id = i; - } - -#define OBJ_PER_ISEC_THREAD 8 /* Largely arbitrary, no need to be big. */ - for (int i = 0; i < thread_count; i++) { -LineartIsecThread *it = >threads[i]; it->rb = rb; } -#undef OBJ_PER_ISEC_THREAD } static void lineart_destroy_isec_thread(LineartIsecData *d) @@ -3249,6 +3248,8 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, LineartIsecThread *th, int up_to) { + BLI_assert(th != NULL); + if (!th) { return; } @@ -3263,7 +3264,7 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, /* If this _is_ the smallest subdiv bounding area, then do the intersections there. */ for (int i = 0; i < up_to; i++) { do { - testing_triangle = (LineartTriangle
[Bf-blender-cvs] [c3a125d4cc0] lineart-shadow: LineArt: Silhouette bit mask logic fix
Commit: c3a125d4cc08c1e75312360c303d61b002ed34da Author: YimingWu Date: Mon May 30 11:58:04 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBc3a125d4cc08c1e75312360c303d61b002ed34da LineArt: Silhouette bit mask logic fix === M release/datafiles/locale M release/scripts/addons M release/scripts/addons_contrib M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/release/datafiles/locale b/release/datafiles/locale index 647c85462d8..ebc3989630d 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 647c85462d87c3a9d3a189d28d72d1bd93f4d4a8 +Subproject commit ebc3989630d18afe00624fc5e4bae6cc0de7a260 diff --git a/release/scripts/addons b/release/scripts/addons index d936e4c01fa..1c8e7f124d1 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit d936e4c01fa263a71a7d0665628ae621283b15ee +Subproject commit 1c8e7f124d17b64ff05cbe179264ba7c7c3aa9fc diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 61e45814503..61efd17f87b 16 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 61e45814503f51963c91c51aaf764612e7c5dc72 +Subproject commit 61efd17f87b45c3049091127a5619219f9d2a821 diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 7454068f690..e922a8b9163 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -336,11 +336,13 @@ static void lineart_edge_cut(LineartRenderBuffer *rb, /* Currently only register lit/shade, see LineartEdgeSegment::shadow_mask_bits for details. */ if (shadow_bits == LRT_SHADOW_MASK_ENCLOSED_SHAPE) { - if (es->shadow_mask_bits == LRT_SHADOW_MASK_LIT || e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { -es->shadow_mask_bits = LRT_SHADOW_MASK_INHIBITED; + if (es->shadow_mask_bits & LRT_SHADOW_MASK_LIT || e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { +es->shadow_mask_bits &= ~LRT_SHADOW_MASK_LIT; +es->shadow_mask_bits |= LRT_SHADOW_MASK_INHIBITED; } - else if (es->shadow_mask_bits == LRT_SHADOW_MASK_SHADED) { -es->shadow_mask_bits = LRT_SHADOW_MASK_LIT; + else if (es->shadow_mask_bits & LRT_SHADOW_MASK_SHADED) { +es->shadow_mask_bits &= ~LRT_SHADOW_MASK_SHADED; +es->shadow_mask_bits |= LRT_SHADOW_MASK_LIT; } } else { @@ -4098,7 +4100,6 @@ static void lineart_bounding_area_split(LineartRenderBuffer *rb, LineartBoundingArea *ba = lineart_mem_acquire_thread(>render_data_pool, sizeof(LineartBoundingArea) * 4); LineartTriangle *tri; - LineartBoundingArea *ba = root->child; ba[0].l = root->cx; ba[0].r = root->r; @@ -6421,9 +6422,9 @@ static void lineart_gpencil_generate(LineartCache *cache, if (ec->shadow_mask_bits != LRT_SHADOW_MASK_UNDEFINED) { /* TODO(Yiming): Give a behaviour option for how to display undefined shadow info. */ if ((shaodow_selection == LRT_SHADOW_FILTER_LIT && - ec->shadow_mask_bits != LRT_SHADOW_MASK_LIT) || + (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_LIT))) || (shaodow_selection == LRT_SHADOW_FILTER_SHADED && - ec->shadow_mask_bits != LRT_SHADOW_MASK_SHADED)) { + (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_SHADED { continue; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b6cfc82ca94] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: b6cfc82ca94dd1cfb1222f8dab76157f5ec99850 Author: YimingWu Date: Mon May 30 09:50:12 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBb6cfc82ca94dd1cfb1222f8dab76157f5ec99850 Merge branch 'temp-lineart-contained' into lineart-shadow === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5d1c589f43f] lineart-shadow: LineArt: Use double to pass isect arg
Commit: 5d1c589f43fe2b5620de55c3485f3ab243aaf5a9 Author: YimingWu Date: Mon May 23 23:13:49 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB5d1c589f43fe2b5620de55c3485f3ab243aaf5a9 LineArt: Use double to pass isect arg === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index d0a834ee2dd..ef914d2cea8 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3289,7 +3289,7 @@ static LineartVert *lineart_triangle_share_point(const LineartTriangle *l, } static bool lineart_triangle_2v_intersection_math( -LineartVert *v1, LineartVert *v2, LineartTriangle *t2, float *last, float *rv) +LineartVert *v1, LineartVert *v2, LineartTriangle *t2, double *last, double *rv) { double Lv[3]; double Rv[3]; @@ -3324,17 +3324,17 @@ static bool lineart_triangle_2v_intersection_math( return false; } - copy_v3fl_v3db(rv, gloc); + copy_v3_v3_db(rv, gloc); return true; } static bool lineart_triangle_intersect_math(LineartTriangle *tri, LineartTriangle *t2, -float *v1, -float *v2) +double *v1, +double *v2) { - float *next = v1, *last = NULL; + double *next = v1, *last = NULL; LineartVert *sv1, *sv2; LineartVert *share = lineart_triangle_share_point(t2, tri); @@ -3345,7 +3345,7 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri, lineart_triangle_get_other_verts(tri, share, , ); -copy_v3fl_v3db(v1, share->gloc); +copy_v3_v3_db(v1, share->gloc); if (!lineart_triangle_2v_intersection_math(sv1, sv2, t2, 0, v2)) { lineart_triangle_get_other_verts(t2, share, , ); @@ -3403,8 +3403,8 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri, } static void lineart_add_isec_thread(LineartIsecThread *th, -const float *v1, -const float *v2, +const double *v1, +const double *v2, LineartTriangle *tri1, LineartTriangle *tri2) { @@ -3418,8 +3418,8 @@ static void lineart_add_isec_thread(LineartIsecThread *th, th->array = new_array; } LineartIsecSingle *is = >array[th->current]; - copy_v3_v3(is->v1, v1); - copy_v3_v3(is->v2, v2); + copy_v3fl_v3db(is->v1, v1); + copy_v3fl_v3db(is->v2, v2); is->tri1 = tri1; is->tri2 = tri2; th->current++; @@ -3550,7 +3550,7 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, /* If we do need to compute intersection, then finally do it. */ -float iv1[3], iv2[3]; +double iv1[3], iv2[3]; if (lineart_triangle_intersect_math(tri, testing_triangle, iv1, iv2)) { lineart_add_isec_thread(th, iv1, iv2, tri, testing_triangle); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [531fcb9f32d] lineart-shadow: Merge branch 'master' into temp-lineart-contained
Commit: 531fcb9f32db4693df56e51a961e25f0b629eb36 Author: YimingWu Date: Mon May 30 09:45:58 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB531fcb9f32db4693df56e51a961e25f0b629eb36 Merge branch 'master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fdc2b7bfa4a] master: Intern: Adding atomic_load/store support for different types.
Commit: fdc2b7bfa4a42951b7fce42544bb1ec16233d681 Author: YimingWu Date: Thu May 26 23:06:36 2022 +0800 Branches: master https://developer.blender.org/rBfdc2b7bfa4a42951b7fce42544bb1ec16233d681 Intern: Adding atomic_load/store support for different types. Mostly using built-in `__atomic` functions, with a special code path using `MemoryBarrier()`on windows. Authored By: Sergey Sharybin (sergey) Reviewed By: Sergey Sharybin (sergey), Ray molenkamp (LazyDodo) Ref D15020 === M intern/atomic/atomic_ops.h M intern/atomic/intern/atomic_ops_ext.h M intern/atomic/intern/atomic_ops_msvc.h M intern/atomic/intern/atomic_ops_unix.h M intern/atomic/tests/atomic_test.cc === diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h index 6a4d6d263c0..2bedce1b4f0 100644 --- a/intern/atomic/atomic_ops.h +++ b/intern/atomic/atomic_ops.h @@ -64,16 +64,22 @@ ATOMIC_INLINE uint64_t atomic_sub_and_fetch_uint64(uint64_t *p, uint64_t x); ATOMIC_INLINE uint64_t atomic_fetch_and_add_uint64(uint64_t *p, uint64_t x); ATOMIC_INLINE uint64_t atomic_fetch_and_sub_uint64(uint64_t *p, uint64_t x); ATOMIC_INLINE uint64_t atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new); +ATOMIC_INLINE uint64_t atomic_load_uint64(const uint64_t *v); +ATOMIC_INLINE void atomic_store_uint64(uint64_t *p, uint64_t v); ATOMIC_INLINE int64_t atomic_add_and_fetch_int64(int64_t *p, int64_t x); ATOMIC_INLINE int64_t atomic_sub_and_fetch_int64(int64_t *p, int64_t x); ATOMIC_INLINE int64_t atomic_fetch_and_add_int64(int64_t *p, int64_t x); ATOMIC_INLINE int64_t atomic_fetch_and_sub_int64(int64_t *p, int64_t x); ATOMIC_INLINE int64_t atomic_cas_int64(int64_t *v, int64_t old, int64_t _new); +ATOMIC_INLINE int64_t atomic_load_int64(const int64_t *v); +ATOMIC_INLINE void atomic_store_int64(int64_t *p, int64_t v); ATOMIC_INLINE uint32_t atomic_add_and_fetch_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE uint32_t atomic_sub_and_fetch_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new); +ATOMIC_INLINE uint32_t atomic_load_uint32(const uint32_t *v); +ATOMIC_INLINE void atomic_store_uint32(uint32_t *p, uint32_t v); ATOMIC_INLINE uint32_t atomic_fetch_and_add_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE uint32_t atomic_fetch_and_or_uint32(uint32_t *p, uint32_t x); @@ -82,6 +88,8 @@ ATOMIC_INLINE uint32_t atomic_fetch_and_and_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE int32_t atomic_add_and_fetch_int32(int32_t *p, int32_t x); ATOMIC_INLINE int32_t atomic_sub_and_fetch_int32(int32_t *p, int32_t x); ATOMIC_INLINE int32_t atomic_cas_int32(int32_t *v, int32_t old, int32_t _new); +ATOMIC_INLINE int32_t atomic_load_int32(const int32_t *v); +ATOMIC_INLINE void atomic_store_int32(int32_t *p, int32_t v); ATOMIC_INLINE int32_t atomic_fetch_and_add_int32(int32_t *p, int32_t x); ATOMIC_INLINE int32_t atomic_fetch_and_or_int32(int32_t *p, int32_t x); @@ -104,6 +112,8 @@ ATOMIC_INLINE size_t atomic_sub_and_fetch_z(size_t *p, size_t x); ATOMIC_INLINE size_t atomic_fetch_and_add_z(size_t *p, size_t x); ATOMIC_INLINE size_t atomic_fetch_and_sub_z(size_t *p, size_t x); ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new); +ATOMIC_INLINE size_t atomic_load_z(const size_t *v); +ATOMIC_INLINE void atomic_store_z(size_t *p, size_t v); /* Uses CAS loop, see warning below. */ ATOMIC_INLINE size_t atomic_fetch_and_update_max_z(size_t *p, size_t x); diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h index aedf0985169..6ecc47f18be 100644 --- a/intern/atomic/intern/atomic_ops_ext.h +++ b/intern/atomic/intern/atomic_ops_ext.h @@ -102,6 +102,24 @@ ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new) #endif } +ATOMIC_INLINE size_t atomic_load_z(const size_t *v) +{ +#if (LG_SIZEOF_PTR == 8) + return (size_t)atomic_load_uint64((const uint64_t *)v); +#elif (LG_SIZEOF_PTR == 4) + return (size_t)atomic_load_uint32((const uint32_t *)v); +#endif +} + +ATOMIC_INLINE void atomic_store_z(size_t *p, size_t v) +{ +#if (LG_SIZEOF_PTR == 8) + atomic_store_uint64((uint64_t *)p, v); +#elif (LG_SIZEOF_PTR == 4) + atomic_store_uint32((uint32_t *)p, v); +#endif +} + ATOMIC_INLINE size_t atomic_fetch_and_update_max_z(size_t *p, size_t x) { size_t prev_value; diff --git a/intern/atomic/intern/atomic_ops_msvc.h b/intern/atomic/intern/atomic_ops_msvc.h index ea5ae666db9..e65691d3970 100644 --- a/intern/atomic/intern/atomic_ops_msvc.h +++ b/intern/atomic/intern/atomic_ops_msvc.h @@ -49,6 +49,16 @@ # pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #endif +/* TODO(sergey): On x64 platform both read and write of a variable aligned to its type size is + * atomic, so in theory it is possible to avoid memory barrier and gain p
[Bf-blender-cvs] [ef59c8295f0] master: Fix T98355: Line art crash when switch to mesh edit mode.
Commit: ef59c8295f0e04630a0cebae3bd4552d50cae2ba Author: YimingWu Date: Wed May 25 20:40:57 2022 +0800 Branches: master https://developer.blender.org/rBef59c8295f0e04630a0cebae3bd4552d50cae2ba Fix T98355: Line art crash when switch to mesh edit mode. This fix will ensure not to load any meshes that's being edited, thus avoiding crashes. Ref D15022 === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 2d3e37e5723..016b70cedb0 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2362,6 +2362,11 @@ static void lineart_object_load_single_instance(LineartRenderBuffer *rb, } if (ob->type == OB_MESH) { use_mesh = BKE_object_get_evaluated_mesh(ob); +if (use_mesh->edit_mesh) { + /* If the object is being edited, then the mesh is not evaluated fully into the final + * result, do not load them. */ + return; +} } else { use_mesh = BKE_mesh_new_from_object(depsgraph, ob, true, true); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [53f7c220227] master: Fix T98359: Handle object that has no feature lines.
Commit: 53f7c220227ad4041dd9587c0a4091c9408e1625 Author: YimingWu Date: Wed May 25 19:19:26 2022 +0800 Branches: master https://developer.blender.org/rB53f7c220227ad4041dd9587c0a4091c9408e1625 Fix T98359: Handle object that has no feature lines. In case of line art "occlusion only" or contour not enabled, it's possible for an object to not produce any feature lines. This patch checks that to prevent freeing a NULL pointer. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index fe1bbc3fc23..2d3e37e5723 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1753,6 +1753,11 @@ static void lineart_finalize_object_edge_array_reserve(LineartPendingEdges *pe, static void lineart_finalize_object_edge_array(LineartPendingEdges *pe, LineartObjectInfo *obi) { + /* In case of line art "occlusion only" or contour not enabled, it's possible for an object to + * not produce any feature lines. */ + if (!obi->pending_edges.array) { +return; + } memcpy(>array[pe->next], obi->pending_edges.array, sizeof(LineartEdge *) * obi->pending_edges.next); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [14a5a91e0e0] master: LineArt: Use CAS for add_triangles.
Commit: 14a5a91e0e033d712134c112a4778b495bd73ba1 Author: YimingWu Date: Thu May 19 18:56:50 2022 +0800 Branches: master https://developer.blender.org/rB14a5a91e0e033d712134c112a4778b495bd73ba1 LineArt: Use CAS for add_triangles. Using the atomic "compare and swap" method in add_triangles stage dramatically speeds up the add_triangles call and significantly reduced the overall calculation time. This is currently the fastest method we have experimented with so far. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14953 === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 69fc26c99e9..c45209661f6 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,6 +17,7 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc + ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index ad3e1b5d7f2..06370cfb283 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -236,6 +236,9 @@ typedef struct LineartRenderBuffer { ListBase line_buffer_pointers; ListBase triangle_buffer_pointers; + LineartElementLinkNode *isect_scheduled_up_to; + int isect_scheduled_up_to_index; + /** This one's memory is not from main pool and is free()ed after culling stage. */ ListBase triangle_adjacent_pointers; @@ -429,15 +432,19 @@ typedef struct LineartBoundingArea { /** 1,2,3,4 quadrant */ struct LineartBoundingArea *child; + SpinLock lock; + ListBase lp; ListBase rp; ListBase up; ListBase bp; - uint16_t triangle_count; - uint16_t max_triangle_count; - uint16_t line_count; - uint16_t max_line_count; + /* Need uint32 for the atomic cas instruction. */ + uint32_t triangle_count; + uint32_t max_triangle_count; + uint32_t line_count; + uint32_t max_line_count; + uint32_t user_count; /* Use array for speeding up multiple accesses. */ struct LineartTriangle **linked_triangles; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index fe1bbc3fc23..e6fce5b799d 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -52,6 +52,38 @@ #include "lineart_intern.h" +#include "atomic_ops.h" + +typedef struct LineartIsecSingle { + float v1[3], v2[3]; + LineartTriangle *tri1, *tri2; +} LineartIsecSingle; + +typedef struct LineartIsecThread { + int thread_id; + + /* Scheduled work range. */ + LineartElementLinkNode *pending_from; + LineartElementLinkNode *pending_to; + int index_from; + int index_to; + + /* Thread intersection result data. */ + LineartIsecSingle *array; + int current; + int max; + int count_test; + + /* For individual thread reference.*/ + LineartRenderBuffer *rb; +} LineartIsecThread; + +typedef struct LineartIsecData { + LineartRenderBuffer *rb; + LineartIsecThread *threads; + int thread_count; +} LineartIsecData; + static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb, LineartEdge *e); @@ -76,14 +108,6 @@ static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb, int *colbegin, int *colend); -static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, -LineartBoundingArea *root_ba, -LineartTriangle *tri, -double *LRUB, -int recursive, -int recursive_level, -bool do_intersection); - static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl, const LineartTriangle *tri, const LineartEdge *e, @@ -99,6 +123,19 @@ static bool lineart_trian
[Bf-blender-cvs] [25d072436d8] lineart-shadow: LineArt: Intersection priority
Commit: 25d072436d84b7e8e4b022d1730ad485b59ba2d2 Author: YimingWu Date: Mon May 23 20:28:55 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB25d072436d84b7e8e4b022d1730ad485b59ba2d2 LineArt: Intersection priority === M release/scripts/startup/bl_ui/properties_collection.py M release/scripts/startup/bl_ui/properties_material.py M release/scripts/startup/bl_ui/properties_object.py M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_collection_types.h M source/blender/makesdna/DNA_material_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesrna/intern/rna_collection.c M source/blender/makesrna/intern/rna_material.c M source/blender/makesrna/intern/rna_object.c === diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py index f2a8f1a2f7d..fd38c07536d 100644 --- a/release/scripts/startup/bl_ui/properties_collection.py +++ b/release/scripts/startup/bl_ui/properties_collection.py @@ -80,12 +80,17 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel): if i == 3: row = col.row(align=True) - row = layout.row(heading="Silouette Group") row.prop(collection, "use_lineart_silhouette_group", text="") subrow = row.row() subrow.active = collection.use_lineart_silhouette_group subrow.prop(collection, "lineart_silhouette_group", text="") + +row = layout.row(heading="Intersection Priority") +row.prop(collection, "use_lineart_intersection_priority", text="") +subrow = row.row() +subrow.active = collection.use_lineart_intersection_priority +subrow.prop(collection, "lineart_intersection_priority", text="") classes = ( diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index d168e576165..da411184900 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -294,6 +294,12 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel): subrow = row.row() subrow.active = lineart.use_silhouette_group_override subrow.prop(lineart, "mat_silhouette_group", text="") + +row = layout.row(heading="Intersection Priority") +row.prop(lineart, "use_intersection_priority_override", text="") +subrow = row.row() +subrow.active = lineart.use_intersection_priority_override +subrow.prop(lineart, "intersection_priority", text="") classes = ( diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 93e237a78d3..dc4115763e5 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -324,6 +324,12 @@ class OBJECT_PT_lineart(ObjectButtonsPanel, Panel): subrow = row.row() subrow.active = lineart.use_silhouette_group_override subrow.prop(lineart, "silhouette_group", text="") + +row = layout.row(heading="Intersection Priority") +row.prop(lineart, "use_intersection_priority_override", text="") +subrow = row.row() +subrow.active = lineart.use_intersection_priority_override +subrow.prop(lineart, "intersection_priority", text="") class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel): diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index c4ea68a9591..21e5ad83f6e 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -351,8 +351,6 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_contour", 0, IFACE_("Contour"), ICON_NONE); - uiLayout *sub = uiLayoutRowWithHeading(col, false, IFACE_("Outline")); uiItemR(sub, ptr, "use_contour", 0, "", ICON_NONE); uiLayout *entry = uiLayoutRow(sub, false); diff --git a/source/blender/gpencil_mo
[Bf-blender-cvs] [3fe1079ecfb] master: Fix T98258: Duplicated last vertex after GPencil sample.
Commit: 3fe1079ecfb4b50936c3ed5d56984fad3c000879 Author: YimingWu Date: Mon May 23 16:15:15 2022 +0800 Branches: master https://developer.blender.org/rB3fe1079ecfb4b50936c3ed5d56984fad3c000879 Fix T98258: Duplicated last vertex after GPencil sample. Also fixed an unreported issue of incorrect interpolation of thickness. Reviewed By: Aleš Jelovčan (frogstomp), Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15005 === M release/datafiles/locale M release/scripts/addons M source/blender/blenkernel/intern/gpencil_geom.cc M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index fb1eac2ec80..647c85462d8 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit fb1eac2ec80c0adee69990a5386b74a5bd4ca00c +Subproject commit 647c85462d87c3a9d3a189d28d72d1bd93f4d4a8 diff --git a/release/scripts/addons b/release/scripts/addons index 7025cd28ede..d936e4c01fa 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 7025cd28ede25eb44208722f842e35b10325c6cc +Subproject commit d936e4c01fa263a71a7d0665628ae621283b15ee diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 041696fa8d3..dd22d64aee1 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -236,6 +236,7 @@ static int stroke_march_next_point(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; +remaining_till_next = 0; break; } } @@ -263,15 +264,18 @@ static int stroke_march_next_point(const bGPDstroke *gps, float ratio = remaining_march / remaining_till_next; interp_v3_v3v3(result, step_start, point, ratio); *ratio_result = ratio; + float d1 = len_v3v3(result, >points[*index_from].x); + float d2 = len_v3v3(result, >points[next_point_index].x); + float vratio = d1 / (d1 + d2); *pressure = interpf( - gps->points[next_point_index].pressure, gps->points[*index_from].pressure, ratio); + gps->points[next_point_index].pressure, gps->points[*index_from].pressure, vratio); *strength = interpf( - gps->points[next_point_index].strength, gps->points[*index_from].strength, ratio); + gps->points[next_point_index].strength, gps->points[*index_from].strength, vratio); interp_v4_v4v4(vert_color, gps->points[*index_from].vert_color, gps->points[next_point_index].vert_color, - ratio); + vratio); return next_point_index == 0 ? gps->totpoints : next_point_index; } @@ -320,6 +324,7 @@ static int stroke_march_next_point_no_interp(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; +remaining_till_next = 0; break; } } diff --git a/source/tools b/source/tools index 53b7c02a062..ccc8fceb6bd 16 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 53b7c02a062c3d6ec6b38ce670836321b4e78fab +Subproject commit ccc8fceb6bd83ffbf6e5207247fb8f76fc47a5b6 ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ac344bd027d] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: ac344bd027da00d39fc610bb0a04ca231e2e499a Author: YimingWu Date: Mon May 23 14:27:26 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBac344bd027da00d39fc610bb0a04ca231e2e499a Merge branch 'temp-lineart-contained' into lineart-shadow === === diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index ee7c82311d8,3abff68fcd5..1db17f810da --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -134,10 -124,21 +126,23 @@@ static bool lineart_triangle_edge_image static void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e); + static void lineart_bounding_area_link_triangle_cas(LineartRenderBuffer *rb, + LineartBoundingArea *root_ba, + LineartTriangle *tri, + double *LRUB, + int recursive, + int recursive_level, + bool do_intersection, + struct LineartIsecThread *th); + + static void lineart_free_bounding_area_memory(LineartBoundingArea *ba, bool recursive); + + static void lineart_free_bounding_area_memories(LineartRenderBuffer *rb); + static LineartCache *lineart_init_cache(void); +static void lineart_clear_linked_edges(LineartRenderBuffer *rb); + static void lineart_discard_segment(LineartRenderBuffer *rb, LineartEdgeSegment *es) { BLI_spin_lock(>lock_cuts); @@@ -2273,14 -2129,8 +2268,14 @@@ static void lineart_geometry_object_loa BLI_spin_unlock(_buf->lock_task); elem_link_node->element_count = allocate_la_e; elem_link_node->object_ref = orig_ob; + elem_link_node->obindex = ob_info->obindex; + + LineartElementLinkNode *shadow_eln = NULL; + if (shadow_elns) { +shadow_eln = lineart_find_matching_eln(shadow_elns, ob_info->obindex); + } - // Start of the edge/seg arr + /* Start of the edge/seg arr */ LineartEdge *la_edge; LineartEdgeSegment *la_seg; la_edge = la_edge_arr; @@@ -2560,17 -2373,17 +2555,21 @@@ static void lineart_object_load_single_ float use_mat[4][4], bool is_render, LineartObjectLoadTaskInfo *olti, --int thread_count) ++int thread_count, ++int obindex) { LineartObjectInfo *obi = lineart_mem_acquire(>render_data_pool, sizeof(LineartObjectInfo)); obi->usage = lineart_usage_check(scene->master_collection, ob, is_render); obi->override_intersection_mask = lineart_intersection_mask_check(scene->master_collection, ob); ++ obi->silhouette_group = lineart_silhouette_group_check(scene->master_collection, ob); Mesh *use_mesh; if (obi->usage == OBJECT_LRT_EXCLUDE) { return; } ++ obi->obindex = obindex << LRT_OBINDEX_SHIFT; ++ /* Prepare the matrix used for transforming this specific object (instance). This has to be * done before mesh boundbox check because the function needs that. */ mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, use_mat); @@@ -2672,6 -2482,6 +2671,10 @@@ static void lineart_main_load_geometrie bool is_render = eval_mode == DAG_EVAL_RENDER; FOREACH_SCENE_OBJECT_BEGIN (scene, ob) { ++/* Do the increment even for discarded objects, so that in different culling conditions we can ++ * get the same reference to the same object. */ ++obindex++; ++ Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob); if (!eval_ob) { @@@ -2679,17 -2489,17 +2682,34 @@@ } if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) { -- lineart_object_load_single_instance( -- rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count); ++ lineart_object_load_single_instance(rb, ++ depsgraph, ++ scene, ++ eval_ob, ++ eval_ob, ++ eval_ob->obmat, ++ is_render, ++ olti, ++ thread_count, ++ o
[Bf-blender-cvs] [679464141c8] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: 679464141c8db8960235c23f5fa2597e1cfcbc32 Author: YimingWu Date: Mon May 23 16:21:53 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB679464141c8db8960235c23f5fa2597e1cfcbc32 Merge branch 'temp-lineart-contained' into lineart-shadow === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [38108373fd0] lineart-shadow: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: 38108373fd008fe5bee36d9737d25e6924794191 Author: YimingWu Date: Mon May 23 16:21:37 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB38108373fd008fe5bee36d9737d25e6924794191 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [abaec1f83ba] lineart-shadow: LineArt: Fix loading.
Commit: abaec1f83bac21ce3b35b44ba576fb3c78467fb3 Author: YimingWu Date: Mon May 23 16:09:23 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBabaec1f83bac21ce3b35b44ba576fb3c78467fb3 LineArt: Fix loading. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 1db17f810da..d364975dc46 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2365,10 +2365,18 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, la_edge->v2 = _v_arr[loose_data.loose_array[i]->v2]; la_edge->flags = LRT_EDGE_FLAG_LOOSE; la_edge->object_ref = orig_ob; + la_edge->from_shadow = (LineartEdge *)LRT_EDGE_IDENTIFIER(ob_info, la_edge); BLI_addtail(_edge->segments, la_seg); if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || usage == OBJECT_LRT_NO_INTERSECTION) { lineart_add_edge_to_array_thread(ob_info, la_edge); +if (shadow_eln) { + LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, + (uint64_t)la_edge->from_shadow); + if (shadow_e) { +lineart_register_shadow_cuts(re_buf, la_edge, shadow_e); + } +} } la_edge++; la_seg++; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cb647370220] lineart-shadow: LineArt: Fix adjacent edge sorting.
Commit: cb6473702208281ac2e528dad1cd968d92d18645 Author: YimingWu Date: Mon May 23 16:08:53 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBcb6473702208281ac2e528dad1cd968d92d18645 LineArt: Fix adjacent edge sorting. The sorting end element should be `start+len` not `start+len-1`. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc index 174399618a5..5e741ccbd55 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc @@ -21,5 +21,5 @@ static bool cmp_adjacent_items(const LineartAdjacentEdge , const LineartAdjac void lineart_sort_adjacent_items(LineartAdjacentEdge *ai, int length) { - blender::parallel_sort(ai, ai + length - 1, cmp_adjacent_items); + blender::parallel_sort(ai, ai + length, cmp_adjacent_items); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ec3b38929e3] lineart-shadow: LineArt: Cas and try to use c11 atomics.
Commit: ec3b38929e330a790641f4657b5b35a878f856cc Author: YimingWu Date: Thu May 19 18:56:50 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBec3b38929e330a790641f4657b5b35a878f856cc LineArt: Cas and try to use c11 atomics. === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 69fc26c99e9..c45209661f6 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,6 +17,7 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc + ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index ad3e1b5d7f2..06370cfb283 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -236,6 +236,9 @@ typedef struct LineartRenderBuffer { ListBase line_buffer_pointers; ListBase triangle_buffer_pointers; + LineartElementLinkNode *isect_scheduled_up_to; + int isect_scheduled_up_to_index; + /** This one's memory is not from main pool and is free()ed after culling stage. */ ListBase triangle_adjacent_pointers; @@ -429,15 +432,19 @@ typedef struct LineartBoundingArea { /** 1,2,3,4 quadrant */ struct LineartBoundingArea *child; + SpinLock lock; + ListBase lp; ListBase rp; ListBase up; ListBase bp; - uint16_t triangle_count; - uint16_t max_triangle_count; - uint16_t line_count; - uint16_t max_line_count; + /* Need uint32 for the atomic cas instruction. */ + uint32_t triangle_count; + uint32_t max_triangle_count; + uint32_t line_count; + uint32_t max_line_count; + uint32_t user_count; /* Use array for speeding up multiple accesses. */ struct LineartTriangle **linked_triangles; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index fe1bbc3fc23..07826b172e7 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -52,6 +52,38 @@ #include "lineart_intern.h" +#include "atomic_ops.h" + +typedef struct LineartIsecSingle { + float v1[3], v2[3]; + LineartTriangle *tri1, *tri2; +} LineartIsecSingle; + +typedef struct LineartIsecThread { + int thread_id; + + /* Scheduled work range. */ + LineartElementLinkNode *pending_from; + LineartElementLinkNode *pending_to; + int index_from; + int index_to; + + /* Thread intersection result data. */ + LineartIsecSingle *array; + int current; + int max; + int count_test; + + /* For individual thread reference.*/ + LineartRenderBuffer *rb; +} LineartIsecThread; + +typedef struct LineartIsecData { + LineartRenderBuffer *rb; + LineartIsecThread *threads; + int thread_count; +} LineartIsecData; + static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb, LineartEdge *e); @@ -76,14 +108,6 @@ static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb, int *colbegin, int *colend); -static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, -LineartBoundingArea *root_ba, -LineartTriangle *tri, -double *LRUB, -int recursive, -int recursive_level, -bool do_intersection); - static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl, const LineartTriangle *tri, const LineartEdge *e, @@ -99,6 +123,19 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl, static void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e); +static void lineart_bounding_area_link_triangle_cas(LineartRenderBuffer *rb, +LineartBo
[Bf-blender-cvs] [0d959dcc53a] lineart-shadow: Merge branch 'master' into temp-lineart-contained
Commit: 0d959dcc53ac40f8c653ae5c11ecaed8503ad6b6 Author: YimingWu Date: Mon May 23 14:05:19 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB0d959dcc53ac40f8c653ae5c11ecaed8503ad6b6 Merge branch 'master' into temp-lineart-contained === === diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 9a7d066c12a,07826b172e7..3abff68fcd5 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -3539,15 -3503,10 +3550,13 @@@ static void lineart_main_bounding_area_ rb->width_per_tile = span_w; rb->height_per_tile = span_h; - rb->bounding_area_count = sp_w * sp_h; + rb->bounding_area_initial_count = sp_w * sp_h; rb->initial_bounding_areas = lineart_mem_acquire( - >render_data_pool, sizeof(LineartBoundingArea) * rb->bounding_area_count); + >render_data_pool, sizeof(LineartBoundingArea) * rb->bounding_area_initial_count); + for (int i = 0; i < rb->bounding_area_initial_count; i++) { +BLI_spin_init(>initial_bounding_areas[i].lock); + } - int i_ba = 0; - /* Initialize tiles. */ for (row = 0; row < sp_h; row++) { for (col = 0; col < sp_w; col++) { @@@ -3826,23 -3788,25 +3838,23 @@@ static void lineart_bounding_area_split b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); b[2] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); b[3] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); - if (LRT_BOUND_AREA_CROSSES(b, [0].l)) { - lineart_bounding_area_link_triangle( - rb, [0], tri, b, 0, recursive_level + 1, false, false, NULL); + if (LRT_BOUND_AREA_CROSSES(b, [0].l)) { + lineart_bounding_area_link_triangle_cas( + rb, [0], tri, b, 0, recursive_level + 1, false, NULL); } - if (LRT_BOUND_AREA_CROSSES(b, [1].l)) { - lineart_bounding_area_link_triangle( - rb, [1], tri, b, 0, recursive_level + 1, false, false, NULL); + if (LRT_BOUND_AREA_CROSSES(b, [1].l)) { + lineart_bounding_area_link_triangle_cas( + rb, [1], tri, b, 0, recursive_level + 1, false, NULL); } - if (LRT_BOUND_AREA_CROSSES(b, [2].l)) { - lineart_bounding_area_link_triangle( - rb, [2], tri, b, 0, recursive_level + 1, false, false, NULL); + if (LRT_BOUND_AREA_CROSSES(b, [2].l)) { + lineart_bounding_area_link_triangle_cas( + rb, [2], tri, b, 0, recursive_level + 1, false, NULL); } - if (LRT_BOUND_AREA_CROSSES(b, [3].l)) { - lineart_bounding_area_link_triangle( - rb, [3], tri, b, 0, recursive_level + 1, false, false, NULL); + if (LRT_BOUND_AREA_CROSSES(b, [3].l)) { + lineart_bounding_area_link_triangle_cas( + rb, [3], tri, b, 0, recursive_level + 1, false, NULL); } } - - rb->bounding_area_count += 3; } static bool lineart_bounding_area_edge_intersect(LineartRenderBuffer *UNUSED(fb), diff --cc source/blender/makesdna/DNA_gpencil_modifier_defaults.h index 9ebfeb18fdc,ae47bf5d524..a8a90c4d154 --- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h @@@ -303,11 -303,10 +303,12 @@@ .crease_threshold = DEG2RAD(140.0f), \ .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES | \ LRT_USE_CREASE_ON_SHARP_EDGES | LRT_FILTER_FACE_MARK_KEEP_CONTOUR, \ - .angle_splitting_threshold = 0.0f, /* Do not split by default, this is for better chaining quality. */ \ + /* Do not split by default, this is for better chaining quality. */ \ + .angle_splitting_threshold = 0.0f, \ .chaining_image_threshold = 0.001f, \ -.chain_smooth_tolerance = 0.2f,\ +.stroke_depth_offset = 0.05,\ +.chain_smooth_tolerance = 0.0f,\ +.overscan = 0.1f,\ .stroke_depth_offset = 0.05,\ } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f4101ba4a10] master: LineArt: Fix adjacent edge sorting.
Commit: f4101ba4a104997551c3261bfab392d76b2e2717 Author: YimingWu Date: Mon May 23 16:08:53 2022 +0800 Branches: master https://developer.blender.org/rBf4101ba4a104997551c3261bfab392d76b2e2717 LineArt: Fix adjacent edge sorting. The sorting end element should be `start+len` not `start+len-1`. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc index 174399618a5..5e741ccbd55 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc @@ -21,5 +21,5 @@ static bool cmp_adjacent_items(const LineartAdjacentEdge , const LineartAdjac void lineart_sort_adjacent_items(LineartAdjacentEdge *ai, int length) { - blender::parallel_sort(ai, ai + length - 1, cmp_adjacent_items); + blender::parallel_sort(ai, ai + length, cmp_adjacent_items); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c4e5a7d59a0] blender-v3.2-release: Fix T98258: Duplicated last vertex after GPencil sample.
Commit: c4e5a7d59a06e833d9e4de45d4eb3cf632a1e9e4 Author: YimingWu Date: Mon May 23 16:15:15 2022 +0800 Branches: blender-v3.2-release https://developer.blender.org/rBc4e5a7d59a06e833d9e4de45d4eb3cf632a1e9e4 Fix T98258: Duplicated last vertex after GPencil sample. Also fixed an unreported issue of incorrect interpolation of thickness. Reviewed By: Aleš Jelovčan (frogstomp), Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15005 === M release/datafiles/locale M release/scripts/addons M source/blender/blenkernel/intern/gpencil_geom.cc M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index fb1eac2ec80..647c85462d8 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit fb1eac2ec80c0adee69990a5386b74a5bd4ca00c +Subproject commit 647c85462d87c3a9d3a189d28d72d1bd93f4d4a8 diff --git a/release/scripts/addons b/release/scripts/addons index 7025cd28ede..d936e4c01fa 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 7025cd28ede25eb44208722f842e35b10325c6cc +Subproject commit d936e4c01fa263a71a7d0665628ae621283b15ee diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 041696fa8d3..dd22d64aee1 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -236,6 +236,7 @@ static int stroke_march_next_point(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; +remaining_till_next = 0; break; } } @@ -263,15 +264,18 @@ static int stroke_march_next_point(const bGPDstroke *gps, float ratio = remaining_march / remaining_till_next; interp_v3_v3v3(result, step_start, point, ratio); *ratio_result = ratio; + float d1 = len_v3v3(result, >points[*index_from].x); + float d2 = len_v3v3(result, >points[next_point_index].x); + float vratio = d1 / (d1 + d2); *pressure = interpf( - gps->points[next_point_index].pressure, gps->points[*index_from].pressure, ratio); + gps->points[next_point_index].pressure, gps->points[*index_from].pressure, vratio); *strength = interpf( - gps->points[next_point_index].strength, gps->points[*index_from].strength, ratio); + gps->points[next_point_index].strength, gps->points[*index_from].strength, vratio); interp_v4_v4v4(vert_color, gps->points[*index_from].vert_color, gps->points[next_point_index].vert_color, - ratio); + vratio); return next_point_index == 0 ? gps->totpoints : next_point_index; } @@ -320,6 +324,7 @@ static int stroke_march_next_point_no_interp(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; +remaining_till_next = 0; break; } } diff --git a/source/tools b/source/tools index 53b7c02a062..ccc8fceb6bd 16 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 53b7c02a062c3d6ec6b38ce670836321b4e78fab +Subproject commit ccc8fceb6bd83ffbf6e5207247fb8f76fc47a5b6 ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a9de546daab] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: a9de546daabc42cf0f30a8d95a72eaba7c2d82b7 Author: YimingWu Date: Wed May 18 15:43:59 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBa9de546daabc42cf0f30a8d95a72eaba7c2d82b7 Merge branch 'temp-lineart-contained' into lineart-shadow === === diff --cc source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index e5eec589dde,f9722ec94c1..86298f2f319 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@@ -513,26 -382,11 +490,15 @@@ typedef struct LineartObjectInfo LineartElementLinkNode *eln; int usage; uint8_t override_intersection_mask; + uint8_t silhouette_group; int global_i_offset; + /* Shifted LRT_OBINDEX_SHIFT bits to be combined with object triangle index. */ + int obindex; + 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; - ListBase material; - ListBase edge_mark; - ListBase floating; - ListBase light_contour; - ListBase shadow; - - /* Note: Data here are allocated with MEM_xxx call instead of in pool. */ + /* Note: Data inside #pending_edges are allocated with MEM_xxx call instead of in pool. */ struct LineartPendingEdges pending_edges; } LineartObjectInfo; diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e61df9e2639,9a7d066c12a..ee7c82311d8 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -2319,11 -2153,11 +2298,11 @@@ static void lineart_geometry_object_loa continue; } - bool edge_added = false; + LineartEdge *edge_added = NULL; /* See eLineartEdgeFlag for details. */ -for (int flag_bit = 0; flag_bit < LRT_EDGE_FLAG_TYPE_MAX_BITS; flag_bit++) { - char use_type = 1 << flag_bit; +for (int flag_bit = 0; flag_bit < LRT_MESH_EDGE_TYPES_COUNT; flag_bit++) { + int use_type = LRT_MESH_EDGE_TYPES[flag_bit]; if (!(use_type & edge_nabr->flags)) { continue; } @@@ -2344,33 -2178,17 +2323,37 @@@ } la_edge->flags = use_type; la_edge->object_ref = orig_ob; + la_edge->from_shadow = (LineartEdge *)LRT_EDGE_IDENTIFIER(ob_info, la_edge); + la_edge->silhouette_group = (re_buf->shadow_use_silhouette && + (la_edge->t1 || (la_edge->t1 && la_edge->t2 && + la_edge->t1->silhouette_group == + la_edge->t2->silhouette_group))) ? + la_edge->t1->silhouette_group : + 0; + la_seg->silhouette_group = la_edge->silhouette_group; BLI_addtail(_edge->segments, la_seg); + + if (shadow_eln) { +/* TODO(Yiming): It's gonna be faster to do this operation after second stage occlusion if + * we only need visible segments to have shadow info, however that way we lose information + * on "shadow behind transparency window" type of region. */ +LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, + (uint64_t)la_edge->from_shadow); +if (shadow_e) { + lineart_register_shadow_cuts(re_buf, la_edge, shadow_e); +} + } + if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || usage == OBJECT_LRT_NO_INTERSECTION) { - lineart_add_edge_to_list_thread(ob_info, la_edge); + lineart_add_edge_to_array_thread(ob_info, la_edge); } - edge_added = true; + if (edge_added) { + edge_added->flags |= LRT_EDGE_FLAG_NEXT_IS_DUPLICATION; + } + + edge_added = la_edge; la_edge++; la_seg++; @@@ -2412,12 -2230,14 +2395,12 @@@ static void lineart_object_load_worker( //- Print size of pending objects. //- Try to feed this with an array instead of via the pool instead of a custom list //- Assign the number of objects instead of number of threads - // printf("thread start: %d\n", olti->thread_id); for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) { -lineart_geometry_object_load(obi, olti->rb); +lineart_geometry_object_load(obi, olti->rb, olti->shadow_elns); if (G.debug_value == 4000) { - printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->to
[Bf-blender-cvs] [c4e9966f4f0] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: c4e9966f4f0997319521c6edca6d65f221e5a856 Author: YimingWu Date: Wed May 18 15:41:06 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBc4e9966f4f0997319521c6edca6d65f221e5a856 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === diff --cc source/blender/makesdna/DNA_gpencil_modifier_defaults.h index bb88e657635,b35d6e750f4..9ebfeb18fdc --- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h @@@ -303,11 -303,9 +303,11 @@@ .crease_threshold = DEG2RAD(140.0f), \ .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES | \ LRT_USE_CREASE_ON_SHARP_EDGES | LRT_FILTER_FACE_MARK_KEEP_CONTOUR, \ - .angle_splitting_threshold = 0.0f, /* Do not split by default, this is for better chaining quality. */ \ + .angle_splitting_threshold = 0.0f, /* Do not split by default, this is for better chaining quality. */ \ .chaining_image_threshold = 0.001f, \ -.chain_smooth_tolerance = 0.2f,\ +.stroke_depth_offset = 0.05,\ +.chain_smooth_tolerance = 0.0f,\ +.overscan = 0.1f,\ .stroke_depth_offset = 0.05,\ } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [016e452b5f9] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: 016e452b5f954ff1cfef78ddcdc82c56d82f8495 Author: YimingWu Date: Sun May 15 22:16:54 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB016e452b5f954ff1cfef78ddcdc82c56d82f8495 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index bddb6b23b85,11d368b819c..dfd98e64511 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -2435,17 -2505,9 +2494,9 @@@ static void lineart_main_load_geometrie BLI_listbase_clear(>triangle_buffer_pointers); BLI_listbase_clear(>vertex_buffer_pointers); - int flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | - DEG_ITER_OBJECT_FLAG_VISIBLE; - - /* Instance duplicated & particles. */ - if (allow_duplicates) { - flags |= DEG_ITER_OBJECT_FLAG_DUPLI; - } - int thread_count = rb->thread_count; - /* This memory is in render buffer memory pool. so we don't need to free those after loading. + /* This memory is in render buffer memory pool. So we don't need to free those after loading. */ LineartObjectLoadTaskInfo *olti = lineart_mem_acquire( >render_data_pool, sizeof(LineartObjectLoadTaskInfo) * thread_count); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d89608cb04b] temp-lineart-contained: LineArt: Use thread safe bound box.
Commit: d89608cb04b3832f3e731afb620a8e8c74df249a Author: YimingWu Date: Tue May 10 14:41:35 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBd89608cb04b3832f3e731afb620a8e8c74df249a LineArt: Use thread safe bound box. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c7d06b1ae7c..bddb6b23b85 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2347,18 +2347,21 @@ static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], double shift_x, double shift_y, - Object *use_ob) + Mesh *use_mesh) { - const BoundBox *bb = BKE_object_boundbox_get(use_ob); - if (!bb) { -/* For lights and empty stuff there will be no bbox. */ + if (!use_mesh) { return false; } + float mesh_min[3], mesh_max[3]; + INIT_MINMAX(mesh_min, mesh_max); + BKE_mesh_minmax(use_mesh, mesh_min, mesh_max); + BoundBox bb = {0}; + BKE_boundbox_init_from_minmax(, mesh_min, mesh_max); double co[8][4]; double tmp[3]; for (int i = 0; i < 8; i++) { -copy_v3db_v3fl(co[i], bb->vec[i]); +copy_v3db_v3fl(co[i], bb.vec[i]); copy_v3_v3_db(tmp, co[i]); mul_v4_m4v3_db(co[i], model_view_proj, tmp); co[i][0] -= shift_x * 2 * co[i][3]; @@ -2470,13 +2473,6 @@ static void lineart_main_load_geometries( continue; } -if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, rb->shift_y, use_ob)) { - if (G.debug_value == 4000) { -bound_box_discard_count++; - } - continue; -} - if (use_ob->type == OB_MESH) { use_mesh = BKE_object_get_evaluated_mesh(use_ob); } @@ -2495,6 +2491,17 @@ static void lineart_main_load_geometries( continue; } +if (!lineart_geometry_check_visible( +obi->model_view_proj, rb->shift_x, rb->shift_y, use_mesh)) { + if (ob->type != OB_MESH) { +BKE_id_free(NULL, use_mesh); + } + if (G.debug_value == 4000) { +bound_box_discard_count++; + } + continue; +} + if (ob->type != OB_MESH) { obi->free_use_mesh = true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7f004860b99] temp-lineart-contained: LineArt: Use safe remove_duplicated_edges
Commit: 7f004860b993e739d40c049485c9479d3cd6571c Author: YimingWu Date: Tue May 10 15:06:31 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB7f004860b993e739d40c049485c9479d3cd6571c LineArt: Use safe remove_duplicated_edges === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_lineart_types.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 7761b1201fe..c7d06b1ae7c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -766,10 +766,9 @@ static bool lineart_edge_match(LineartTriangle *tri, LineartEdge *e, int v1, int static void lineart_discard_duplicated_edges(LineartEdge *old_e, int v1id, int v2id) { LineartEdge *e = old_e; - e++; - while (e->v1 && e->v2 && e->v1->index == v1id && e->v2->index == v2id) { -e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; + while (e->flags & LRT_EDGE_FLAG_NEXT_IS_DUPLICATION) { e++; +e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; } } @@ -2171,7 +2170,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, LineartRend continue; } -bool edge_added = false; +LineartEdge *edge_added = NULL; /* See eLineartEdgeFlag for details. */ for (int flag_bit = 0; flag_bit < LRT_EDGE_FLAG_TYPE_MAX_BITS; flag_bit++) { @@ -2202,7 +2201,11 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, LineartRend lineart_add_edge_to_list_thread(ob_info, la_edge); } - edge_added = true; + if (edge_added) { +edge_added->flags |= LRT_EDGE_FLAG_NEXT_IS_DUPLICATION; + } + + edge_added = la_edge; la_edge++; la_seg++; @@ -2244,14 +2247,14 @@ static void lineart_object_load_worker(TaskPool *__restrict UNUSED(pool), //- Print size of pending objects. //- Try to feed this with an array instead of via the pool instead of a custom list //- Assign the number of objects instead of number of threads - printf("thread start: %d\n", olti->thread_id); + // printf("thread start: %d\n", olti->thread_id); for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) { lineart_geometry_object_load(obi, olti->rb); if (G.debug_value == 4000) { - printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); + // printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); } } - printf("thread end: %d\n", olti->thread_id); + // printf("thread end: %d\n", olti->thread_id); } static uchar lineart_intersection_mask_check(Collection *c, Object *ob) diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h index e3aa6eb1156..3b0f2baa310 100644 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@ -59,6 +59,8 @@ typedef enum eLineartEdgeFlag { /** For object loading code to use only. */ LRT_EDGE_FLAG_INHIBIT = (1 << 14), + /** For discarding duplicated edge types in culling stage. */ + LRT_EDGE_FLAG_NEXT_IS_DUPLICATION = (1 << 15), } eLineartEdgeFlag; #define LRT_EDGE_FLAG_ALL_TYPE 0x7f ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [795109bba3d] temp-lineart-contained: LineArt: Cleanup variables.
Commit: 795109bba3dc68a39171dc7c6728b649da3b1419 Author: YimingWu Date: Mon May 9 22:06:36 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB795109bba3dc68a39171dc7c6728b649da3b1419 LineArt: Cleanup variables. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 31c41d2c9fb..7761b1201fe 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -444,8 +444,6 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge * static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRenderTaskInfo *rti) { - LineartEdge *data; - int i; int res = 0; int starting_index; @@ -1464,8 +1462,6 @@ static void lineart_mvert_transform_task(void *__restrict userdata, v->index = i; } -#define LRT_EDGE_FLAG_TYPE_MAX_BITS 6 - static int lineart_edge_type_duplication_count(char eflag) { int count = 0; @@ -3537,7 +3533,6 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb) int sp_h = LRT_BA_ROWS; int row, col; LineartBoundingArea *ba; - int lock_group_inc = sp_w * sp_h / rb->thread_count; /* Because NDC (Normalized Device Coordinates) range is (-1,1), * so the span for each initial tile is double of that in the (0,1) range. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8202d2b3568] temp-lineart-contained: LineArt: Fix wrong user data reference.
Commit: 8202d2b3568dafc6866683779498ef9e412c5b68 Author: YimingWu Date: Mon May 9 22:06:02 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB8202d2b3568dafc6866683779498ef9e412c5b68 LineArt: Fix wrong user data reference. the user data in lineart_identify_loose_edges should be the `tls` one rather than the plain `userdata`. This will lead to incorrect address being accessed. Fixed now. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index f93b2350098..31c41d2c9fb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1741,11 +1741,11 @@ static void lineart_add_loose_edge(LooseEdgeData *loose_data, MEdge *e) loose_data->loose_count++; } -static void lineart_identify_loose_edges(void *__restrict userdata, +static void lineart_identify_loose_edges(void *__restrict UNUSED(userdata), const int i, - const TaskParallelTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict tls) { - LooseEdgeData *loose_data = (LooseEdgeData *)userdata; + LooseEdgeData *loose_data = (LooseEdgeData *)tls->userdata_chunk; Mesh *me = loose_data->me; if (me->medge[i].flag & ME_LOOSEEDGE) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9f8254fd34a] master: LineArt: Remove LineartEdge::obindex.
Commit: 9f8254fd34ac397147b531747122d8853014c89c Author: YimingWu Date: Wed May 18 15:31:41 2022 +0800 Branches: master https://developer.blender.org/rB9f8254fd34ac397147b531747122d8853014c89c LineArt: Remove LineartEdge::obindex. After changing the duplicated edge removal method in D14903, these two obindex variables are no longer needed. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14949 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c 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 8ce36bc0254..12c1e9cf563 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -122,11 +122,7 @@ typedef struct LineartEdge { /** We only need link node kind of list here. */ struct LineartEdge *next; struct LineartVert *v1, *v2; - /** - * Local vertex index for two ends, not pouting in #RenderVert because all verts are loaded, so - * as long as fewer than half of the mesh edges are becoming a feature line, we save more memory. - */ - int v1_obindex, v2_obindex; + struct LineartTriangle *t1, *t2; ListBase segments; char min_occ; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 0ee990e0f77..226b8f532b5 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -219,7 +219,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, -e->v1_obindex); +e->v1->index); while (ba && (new_e = lineart_line_get_connected( ba, new_vt, _vt, e->flags, e->intersection_mask))) { new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; @@ -256,7 +256,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, es->occlusion, es->material_mask_bits, - new_e->v1_obindex); + new_e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -282,7 +282,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, - new_e->v2_obindex); + new_e->v2->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -295,7 +295,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, -new_e->v2_obindex); +new_e->v2->index); } ba = MOD_lineart_get_bounding_area(rb, new_vt->fbcoord[0], new_vt->fbcoord[1]); } @@ -336,7 +336,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, - e->v1_obindex); + e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -349,7 +349,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, last_occlusion, last_transparency, - e->v2_obindex); + e->v2->index); /* Step 3: grow right. */ ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]); @@ -402,7 +402,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
[Bf-blender-cvs] [6f00b1500cb] master: LineArt: Use array instead of lists for edges pending occusion query
Commit: 6f00b1500cbd162dfe2fa7f8de2c46f156f75da4 Author: YimingWu Date: Wed May 18 15:33:35 2022 +0800 Branches: master https://developer.blender.org/rB6f00b1500cbd162dfe2fa7f8de2c46f156f75da4 LineArt: Use array instead of lists for edges pending occusion query It turns out there's no practical use for separating different edge types before final occlusion stage, also using an array should be faster overall. So changed those lists into one pending array, it also made the iteration and occlusion task scheduling simpler. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14951 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 12c1e9cf563..06738ef6a12 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -204,6 +204,12 @@ enum eLineArtTileRecursiveLimit { #define LRT_TILE_SPLITTING_TRIANGLE_LIMIT 100 #define LRT_TILE_EDGE_COUNT_INITIAL 32 +typedef struct LineartPendingEdges { + LineartEdge **array; + int max; + int next; +} LineartPendingEdges; + typedef struct LineartRenderBuffer { struct LineartRenderBuffer *prev, *next; @@ -248,15 +254,9 @@ typedef struct LineartRenderBuffer { int triangle_size; - /* Although using ListBase here, LineartEdge is single linked list. - * list.last is used to store worker progress along the list. - * See lineart_main_occlusion_begin() for more info. */ - ListBase contour; - ListBase intersection; - ListBase crease; - ListBase material; - ListBase edge_mark; - ListBase floating; + /* Note: Data inside #pending_edges are allocated with MEM_xxx call instead of in pool. */ + struct LineartPendingEdges pending_edges; + int scheduled_count; ListBase chains; @@ -362,14 +362,9 @@ typedef struct LineartRenderTaskInfo { int thread_id; - /* These lists only denote the part of the main edge list that the thread should iterate over. - * Be careful to not iterate outside of these bounds as it is not thread safe to do so. */ - ListBase contour; - ListBase intersection; - ListBase crease; - ListBase material; - ListBase edge_mark; - ListBase floating; + /* #pending_edges here only stores a refernce to a portion in LineartRenderbuffer::pending_edges, + * assigned by the occlusion scheduler. */ + struct LineartPendingEdges pending_edges; } LineartRenderTaskInfo; @@ -387,14 +382,8 @@ typedef struct LineartObjectInfo { 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; - ListBase material; - ListBase edge_mark; - ListBase floating; + /* Note: Data inside #pending_edges are allocated with MEM_xxx call instead of in pool. */ + struct LineartPendingEdges pending_edges; } LineartObjectInfo; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 08a8aed41c0..fe1bbc3fc23 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -97,7 +97,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl, double *from, double *to); -static void lineart_add_edge_to_list(LineartRenderBuffer *rb, LineartEdge *e); +static void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e); static LineartCache *lineart_init_cache(void); @@ -412,38 +412,26 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge * static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRenderTaskInfo *rti) { - LineartEdge *data; - int i; int res = 0; + int starting_index; BLI_spin_lock(>lock_task); -#define LRT_ASSIGN_OCCLUSION_TASK(name) \ - if (rb->name.last) { \ -data = rb->name.last; \ -rti->name.first = (void *)data; \ -for (i = 0; i < LRT_THREAD_EDGE_COUNT && data; i++) { \ - data = data->next; \ -} \ -rti->name.last = data; \ -rb->name.last = data; \ -res = 1; \ - } \ - else { \ -rti->name.first = rti->name.last = NULL; \ - } - - LRT_ASSIGN_OCCLUSION_TASK(contour); - LRT_ASSIGN_OCCLUSION_TASK(intersection); - LRT_ASSIGN_OCCLUSION_TASK
[Bf-blender-cvs] [2719869a2a9] master: LineArt: Prioritize connecting chains from the same contour loop
Commit: 2719869a2a98e8a0cb8d229f0efe7b9ec5138720 Author: YimingWu Date: Wed May 18 15:23:43 2022 +0800 Branches: master https://developer.blender.org/rB2719869a2a98e8a0cb8d229f0efe7b9ec5138720 LineArt: Prioritize connecting chains from the same contour loop This change allows the chaining function to select edges from the same contour loop first, thus reduced rouge chain connections (connected different objects instead of chaining inside the same object first) and improved chaining quality. This patch also included the default value change for chain split threshold (Now don't split by default to make initial result as smooth as possible) Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14950 === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/makesdna/DNA_gpencil_modifier_defaults.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 9e44990cfca..8ce36bc0254 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -158,6 +158,8 @@ typedef struct LineartEdgeChain { /** Chain now only contains one type of segments */ int type; + /** Will only connect chains that has the same loop id. */ + int loop_id; unsigned char material_mask_bits; unsigned char intersection_mask; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 28fd8ff01b9..0ee990e0f77 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -617,9 +617,14 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb) rb->chains.last = rb->chains.first = NULL; + int loop_id = 0; while ((ec = BLI_pophead()) != NULL) { ec->next = ec->prev = NULL; BLI_addtail(>chains, ec); + +ec->loop_id = loop_id; +loop_id++; + LineartEdgeChainItem *first_eci = (LineartEdgeChainItem *)ec->chain.first; int fixed_occ = first_eci->occlusion; unsigned char fixed_mask = first_eci->material_mask_bits; @@ -651,6 +656,7 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb) new_ec = lineart_chain_create(rb); new_ec->chain.first = eci; new_ec->chain.last = ec->chain.last; +new_ec->loop_id = loop_id; ec->chain.last = eci->prev; ((LineartEdgeChainItem *)ec->chain.last)->next = 0; eci->prev = 0; @@ -743,6 +749,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf int occlusion, unsigned char material_mask_bits, unsigned char isec_mask, +int loop_id, float dist, float *result_new_len, LineartBoundingArea *caller_ba) @@ -791,7 +798,11 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf float new_len = rb->use_geometry_space_chain ? len_v3v3(cre->eci->gpos, eci->gpos) : len_v2v2(cre->eci->pos, eci->pos); -if (new_len < dist) { +/* Even if the vertex is not from the same contour loop, we try to chain it still if the + * distance is small enough. This way we can better chain smaller loops and smooth them out + * later. */ +if (((cre->ec->loop_id == loop_id) && (new_len < dist)) || +((cre->ec->loop_id != loop_id) && (new_len < dist / 10))) { closest_cre = cre; dist = new_len; if (result_new_len) { @@ -815,6 +826,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf occlusion, \ material_mask_bits, \ isec_mask, \ + loop_id, \ dist, \ _new_len, \
[Bf-blender-cvs] [369f652c804] master: LineArt: Use safe lineart_discard_duplicated_edges
Commit: 369f652c8046955ea83436a138d61a5b130c04c4 Author: YimingWu Date: Wed May 18 15:29:27 2022 +0800 Branches: master https://developer.blender.org/rB369f652c8046955ea83436a138d61a5b130c04c4 LineArt: Use safe lineart_discard_duplicated_edges The old method doesn't check e for array boundary. The new method ensures it only access valid elements. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14903 === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_lineart_types.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 11d368b819c..9f0ab884c58 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -757,13 +757,12 @@ static bool lineart_edge_match(LineartTriangle *tri, LineartEdge *e, int v1, int (tri->v[v2] == e->v1 && tri->v[v1] == e->v2)); } -static void lineart_discard_duplicated_edges(LineartEdge *old_e, int v1id, int v2id) +static void lineart_discard_duplicated_edges(LineartEdge *old_e) { LineartEdge *e = old_e; - e++; - while (e->v1_obindex == v1id && e->v2_obindex == v2id) { -e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; + while (e->flags & LRT_EDGE_FLAG_NEXT_IS_DUPLICATION) { e++; +e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; } } @@ -832,7 +831,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb, old_e = ta->e[e_num]; \ new_flag = old_e->flags; \ old_e->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \ -lineart_discard_duplicated_edges(old_e, old_e->v1_obindex, old_e->v2_obindex); \ +lineart_discard_duplicated_edges(old_e); \ INCREASE_EDGE \ e->v1 = (v1_link); \ e->v2 = (v2_link); \ @@ -853,15 +852,15 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb, #define REMOVE_TRIANGLE_EDGE \ if (ta->e[0]) { \ ta->e[0]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \ -lineart_discard_duplicated_edges(ta->e[0], ta->e[0]->v1_obindex, ta->e[0]->v2_obindex); \ +lineart_discard_duplicated_edges(ta->e[0]); \ } \ if (ta->e[1]) { \ ta->e[1]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \ -lineart_discard_duplicated_edges(ta->e[1], ta->e[1]->v1_obindex, ta->e[1]->v2_obindex); \ +lineart_discard_duplicated_edges(ta->e[1]); \ } \ if (ta->e[2]) { \ ta->e[2]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \ -lineart_discard_duplicated_edges(ta->e[2], ta->e[2]->v1_obindex, ta->e[2]->v2_obindex); \ +lineart_discard_duplicated_edges(ta->e[2]); \ } switch (in0 + in1 + in2) { @@ -2188,7 +2187,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, LineartRend continue; } -bool edge_added = false; +LineartEdge *edge_added = NULL; /* See eLineartEdgeFlag for details. */ for (int flag_bit = 0; flag_bit < LRT_EDGE_FLAG_TYPE_MAX_BITS; flag_bit++) { @@ -2221,7 +2220,11 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, LineartRend lineart_add_edge_to_list_thread(ob_info, la_edge); } - edge_added = true; + if (edge_added) { +edge_added->flags |= LRT_EDGE_FLAG_NEXT_IS_DUPLICATION; + } + + edge_added = la_edge; la_edge++; la_seg++; diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h index 39b75b6eda2..5b3a23000d7 100644 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@ -57,6 +57,8 @@ typedef enum eLineartEdgeFlag { /** For object loading code to use only. */ LRT_EDGE_FLAG_INHIBIT = (1 << 14), + /** For discarding duplicated edge types in culling stage. */ + LRT_EDGE_FLAG_NEXT_IS_DUPLICATION = (1 << 15), } eLineartEdgeFlag; #define LRT_EDGE_FLAG_ALL_TYPE 0x3f ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7c9b6cc3802] master: LineArt: Better behavior of smooth tolerance.
Commit: 7c9b6cc3802982bfb7a13aed37d4a032d9166fbc Author: YimingWu Date: Sat May 14 00:55:18 2022 +0800 Branches: master https://developer.blender.org/rB7c9b6cc3802982bfb7a13aed37d4a032d9166fbc LineArt: Better behavior of smooth tolerance. This fixes the smooth tolerance feature in master where sometimes you could get over simplified chains and lose the shape it's supposed to be originally. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14929 === M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index b666eb677eb..d7b370ef5e5 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -971,27 +971,67 @@ void MOD_lineart_chain_clear_picked_flag(LineartCache *lc) void MOD_lineart_smooth_chains(LineartRenderBuffer *rb, float tolerance) { LISTBASE_FOREACH (LineartEdgeChain *, ec, >chains) { -LineartEdgeChainItem *next_eci; -for (LineartEdgeChainItem *eci = ec->chain.first; eci; eci = next_eci) { - next_eci = eci->next; - LineartEdgeChainItem *eci2, *eci3, *eci4; - - /* Not enough point to do simplify. */ - if ((!(eci2 = eci->next)) || (!(eci3 = eci2->next))) { -continue; - } - - /* No need to care for different line types/occlusion and so on, because at this stage they - * are all the same within a chain. */ - - /* If p3 is within the p1-p2 segment of a width of "tolerance". */ - if (dist_to_line_segment_v2(eci3->pos, eci->pos, eci2->pos) < tolerance) { -/* And if p4 is on the extension of p1-p2 , we remove p3. */ -if ((eci4 = eci3->next) && (dist_to_line_v2(eci4->pos, eci->pos, eci2->pos) < tolerance)) { - BLI_remlink(>chain, eci3); - next_eci = eci; +/* Go through the chain two times, once from each direction. */ +for (int times = 0; times < 2; times++) { + for (LineartEdgeChainItem *eci = ec->chain.first, *next_eci = eci->next; eci; + eci = next_eci) { +LineartEdgeChainItem *eci2, *eci3, *eci4; + +if ((!(eci2 = eci->next)) || (!(eci3 = eci2->next))) { + /* Not enough points to simplify. */ + next_eci = eci->next; + continue; } +/* No need to care for different line types/occlusion and so on, because at this stage they + * are all the same within a chain. + * + * We need to simplify a chain from this: + * 1---2 + *3---4 + * to this: + * 1---2--_ + * `--4 */ + +/* If p3 is within the p1-p2 segment of a width of "tolerance", in other words, p3 is + * approximately on the segment of p1-p2. */ +if (dist_to_line_segment_v2(eci3->pos, eci->pos, eci2->pos) < tolerance) { + float vec2[2], vec3[2], v2n[2], ratio, len2; + sub_v2_v2v2(vec2, eci2->pos, eci->pos); + sub_v2_v2v2(vec3, eci3->pos, eci->pos); + normalize_v2_v2(v2n, vec2); + ratio = dot_v2v2(v2n, vec3); + len2 = len_v2(vec2); + /* Because this smoothing applies on geometries of different scales in the same scene, + * some small scale features (e.g. the "tails" on the inner ring of a torus geometry) + * could be completely erased if the tolerance value is set for accomondating the entire + * scene. Those situations typically result in (ratio << 0), looks like this: + * 1---2 + * 3---4 + * (this sort of long zig zag obviously are "features" that can't be erased) + * setting a ratio of -10 turned out to be a reasonabe threshold in tests. */ + if (ratio < len2 && ratio > -len2 * 10) { +/* We only remove p3 if p4 is on the extension of p1->p2. */ +if ((eci4 = eci3->next) && +(dist_to_line_v2(eci4->pos, eci->pos, eci2->pos) < tolerance)) { + BLI_remlink(>chain, eci3); + next_eci = eci; + continue; +} +if (!eci4) { + /* See if the last segment's direction is reversed, if so remove that. + * Basically we don't need to preserve p3 if the entire chain looked like this: + * ...13===2 */ + if (len_v2(vec2) > len_v2(vec3)) { +BLI_remlink(>chain, eci3
[Bf-blender-cvs] [870ad7d05db] master: Fix T96781: LineArt proper object iterator.
Commit: 870ad7d05db2e14164d818cd5320345fd8110a69 Author: YimingWu Date: Sat May 14 00:03:40 2022 +0800 Branches: master https://developer.blender.org/rB870ad7d05db2e14164d818cd5320345fd8110a69 Fix T96781: LineArt proper object iterator. This patch get rid of the _incorrectly used_ DG iterator in object loading, and uses scene objects iteration to prevent problems. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14907 === M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 0e7df2a136d..a07ef2eb195 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -218,9 +218,18 @@ static void add_this_collection(Collection *c, if (!c) { return; } + bool default_add = true; + /* Do not do nested collection usage check, this is consistent with lineart calculation, because + * collection usage doesn't have a INHERIT mode. This might initially be derived from the fact + * that an object can be inside multiple collections, but might be irrelevant now with the way + * objects are iterated. Keep this logic for now. */ + if (c->lineart_usage & COLLECTION_LRT_EXCLUDE) { +default_add = false; + } FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (c, ob, mode) { if (ELEM(ob->type, OB_MESH, OB_MBALL, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { - if (ob->lineart.usage != OBJECT_LRT_EXCLUDE) { + if ((ob->lineart.usage == OBJECT_LRT_INHERIT && default_add) || + ob->lineart.usage != OBJECT_LRT_EXCLUDE) { DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_GEOMETRY, "Line Art Modifier"); DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_TRANSFORM, "Line Art Modifier"); } @@ -239,15 +248,11 @@ static void updateDepsgraph(GpencilModifierData *md, DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Line Art Modifier"); LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md; - if (lmd->source_type == LRT_SOURCE_OBJECT && lmd->source_object) { -DEG_add_object_relation( -ctx->node, lmd->source_object, DEG_OB_COMP_GEOMETRY, "Line Art Modifier"); -DEG_add_object_relation( -ctx->node, lmd->source_object, DEG_OB_COMP_TRANSFORM, "Line Art Modifier"); - } - else { -add_this_collection(ctx->scene->master_collection, ctx, mode); - } + + /* Always add whole master collection because line art will need the whole scene for + * visibility computation. Line art exclusion is handled inside #add_this_collection. */ + add_this_collection(ctx->scene->master_collection, ctx, mode); + if (lmd->calculation_flags & LRT_USE_CUSTOM_CAMERA && lmd->source_camera) { DEG_add_object_relation( ctx->node, lmd->source_camera, DEG_OB_COMP_TRANSFORM, "Line Art Modifier"); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index b09bb15ce81..11d368b819c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -21,6 +21,7 @@ #include "BKE_collection.h" #include "BKE_customdata.h" #include "BKE_deform.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_gpencil.h" @@ -2398,6 +2399,64 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], return true; } +static void lineart_object_load_single_instance(LineartRenderBuffer *rb, +Depsgraph *depsgraph, +Scene *scene, +Object *ob, +Object *ref_ob, +float use_mat[4][4], +bool is_render, +LineartObjectLoadTaskInfo *olti, +int thread_count) +{ + LineartObjectInfo *obi = lineart_mem_acquire(>render_data_pool, sizeof(LineartObjectInfo)); + obi->usage = lineart_usage_check(scene->master_collection, ob, is_render); + obi->override_intersection_mask = lineart_intersection_mask_check(scene->mas
[Bf-blender-cvs] [cd349dc4023] master: LineArt: Use thread safe bound box.
Commit: cd349dc4023aa1e6b4728ae6804ae36a5e170758 Author: YimingWu Date: Tue May 10 14:41:35 2022 +0800 Branches: master https://developer.blender.org/rBcd349dc4023aa1e6b4728ae6804ae36a5e170758 LineArt: Use thread safe bound box. The old method is not thread safe, which will lead to minor memory leaks. This patch fixed that. Reviewed By: Sebastian Parborg (zeddb) Differential Revision: https://developer.blender.org/D14904 === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index dbe2ae0b890..b09bb15ce81 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2358,18 +2358,21 @@ static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], double shift_x, double shift_y, - Object *use_ob) + Mesh *use_mesh) { - const BoundBox *bb = BKE_object_boundbox_get(use_ob); - if (!bb) { -/* For lights and empty stuff there will be no bbox. */ + if (!use_mesh) { return false; } + float mesh_min[3], mesh_max[3]; + INIT_MINMAX(mesh_min, mesh_max); + BKE_mesh_minmax(use_mesh, mesh_min, mesh_max); + BoundBox bb = {0}; + BKE_boundbox_init_from_minmax(, mesh_min, mesh_max); double co[8][4]; double tmp[3]; for (int i = 0; i < 8; i++) { -copy_v3db_v3fl(co[i], bb->vec[i]); +copy_v3db_v3fl(co[i], bb.vec[i]); copy_v3_v3_db(tmp, co[i]); mul_v4_m4v3_db(co[i], model_view_proj, tmp); co[i][0] -= shift_x * 2 * co[i][3]; @@ -2481,13 +2484,6 @@ static void lineart_main_load_geometries( continue; } -if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, rb->shift_y, use_ob)) { - if (G.debug_value == 4000) { -bound_box_discard_count++; - } - continue; -} - if (use_ob->type == OB_MESH) { use_mesh = BKE_object_get_evaluated_mesh(use_ob); } @@ -2506,6 +2502,17 @@ static void lineart_main_load_geometries( continue; } +if (!lineart_geometry_check_visible( +obi->model_view_proj, rb->shift_x, rb->shift_y, use_mesh)) { + if (ob->type != OB_MESH) { +BKE_id_free(NULL, use_mesh); + } + if (G.debug_value == 4000) { +bound_box_discard_count++; + } + continue; +} + if (ob->type != OB_MESH) { obi->free_use_mesh = true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e8416ce70f0] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: e8416ce70f093b46ec2aabfe7039bf141adb Author: YimingWu Date: Wed May 4 22:36:05 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBe8416ce70f093b46ec2aabfe7039bf141adb Merge branch 'temp-lineart-contained' into lineart-shadow === === diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 0cfd3892489,2756ca20716..bcae97e21df --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -1646,141 -1579,166 +1621,183 @@@ static void lineart_identify_mlooptri_f if (enable_face_mark && !face_mark_filtered && !only_contour) { return; } - else { - /* Mesh boundary */ - if (en[i].e == -1) { - en[i].flags = LRT_EDGE_FLAG_CONTOUR; - reduce_data->feat_edges += 1; - return; - } + /* Mesh boundary */ + if (edge_nabr[i].e == -1) { + edge_nabr[i].flags = LRT_EDGE_FLAG_CONTOUR; + reduce_data->feat_edges += 1; + return; + } - LineartTriangle *tri1, *tri2; - LineartVert *vert; - LineartRenderBuffer *rb = e_feat_data->rb; + LineartTriangle *tri1, *tri2; + LineartVert *vert; + LineartRenderBuffer *rb = e_feat_data->rb; - int f1 = i / 3, f2 = en[i].e / 3; + int f1 = i / 3, f2 = edge_nabr[i].e / 3; - /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ - tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f1); - tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f2); + /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ + tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f1); + tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f2); - vert = _feat_data->v_array[en[i].v1]; + vert = _feat_data->v_array[edge_nabr[i].v1]; - double vv[3]; - double *view_vector = vv; - double dot_1 = 0, dot_2 = 0; - double result; - bool material_back_face = ((tri1->flags | tri2->flags) & LRT_TRIANGLE_MAT_BACK_FACE_CULLING); + double view_vector_persp[3]; + double *view_vector = view_vector_persp; + double dot_1 = 0, dot_2 = 0; + double result; + bool material_back_face = ((tri1->flags | tri2->flags) & LRT_TRIANGLE_MAT_BACK_FACE_CULLING); - if (rb->use_contour || rb->use_back_face_culling || material_back_face) { - if (rb->cam_is_persp) { - sub_v3_v3v3_db(view_vector, rb->camera_pos, vert->gloc); - } - else { - view_vector = rb->view_vector; - } + if (rb->use_contour || rb->use_back_face_culling || material_back_face) { + if (rb->cam_is_persp) { + sub_v3_v3v3_db(view_vector, rb->camera_pos, vert->gloc); + } + else { + view_vector = rb->view_vector; + } - dot_1 = dot_v3v3_db(view_vector, tri1->gn); - dot_2 = dot_v3v3_db(view_vector, tri2->gn); + dot_1 = dot_v3v3_db(view_vector, tri1->gn); + dot_2 = dot_v3v3_db(view_vector, tri2->gn); - if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { - edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; - } + if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { + edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; + } - if (rb->use_back_face_culling) { - if (dot_1 < 0) { - tri1->flags |= LRT_CULL_DISCARD; - } - if (dot_2 < 0) { - tri2->flags |= LRT_CULL_DISCARD; - } + if (rb->use_back_face_culling) { + if (dot_1 < 0) { + tri1->flags |= LRT_CULL_DISCARD; } - if (material_back_face) { - if (tri1->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_1 < 0) { - tri1->flags |= LRT_CULL_DISCARD; - } - if (tri2->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_2 < 0) { - tri2->flags |= LRT_CULL_DISCARD; - } + if (dot_2 < 0) { + tri2->flags |= LRT_CULL_DISCARD; } } - - if (rb->use_contour_secondary) { - view_vector = vv; - if (rb->cam_is_persp_secondary) { - sub_v3_v3v3_db(view_vector, vert->gloc, rb->camera_pos_secondary); + if (material_back_face) { + if (tri1->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_1 < 0) { + tri1->flags |= LRT_CULL_DISCARD; } - else { - view_vector = rb->view_vector_secondary; + if (tri2->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_2 < 0) { + tri2->flags |= LRT_CULL_DISCARD; } + } + } -
[Bf-blender-cvs] [5efc1dea8a4] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: 5efc1dea8a4a44a1fdd2eb75617d91f04eae18cf Author: YimingWu Date: Sat May 7 21:02:32 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB5efc1dea8a4a44a1fdd2eb75617d91f04eae18cf Merge branch 'temp-lineart-contained' into lineart-shadow === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [708eb259e05] temp-lineart-contained: LineArt: Patch review fixes for object load.
Commit: 708eb259e056bce3e92c1f8ea85b5bb184b69c05 Author: YimingWu Date: Wed May 4 21:07:20 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB708eb259e056bce3e92c1f8ea85b5bb184b69c05 LineArt: Patch review fixes for object load. === M source/blender/blenlib/intern/BLI_mempool.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index bc97b71c78e..f70b5ddd766 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -355,7 +355,32 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) { BLI_freenode *newhead = addr; +#ifndef NDEBUG + { +BLI_mempool_chunk *chunk; +bool found = false; +for (chunk = pool->chunks; chunk; chunk = chunk->next) { + if (ARRAY_HAS_ITEM((char *)addr, (char *)CHUNK_DATA(chunk), pool->csize)) { +found = true; +break; + } +} +if (!found) { + BLI_assert_msg(0, "Attempt to free data which is not in pool.\n"); +} + } + + /* Enable for debugging. */ + if (UNLIKELY(mempool_debug_memset)) { +memset(addr, 255, pool->esize); + } +#endif + if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { +#ifndef NDEBUG +/* This will detect double free's. */ +BLI_assert(newhead->freeword != FREEWORD); +#endif newhead->freeword = FREEWORD; } diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 50fe1ec4075..f93a8b4767b 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -14,14 +14,6 @@ #include -typedef struct EdgeFacePair { - int v1; - int v2; - int f1; - int f2; - uint16_t eflag; -} EdgeFacePair; - typedef struct LineartStaticMemPoolNode { Link item; size_t size; @@ -177,7 +169,7 @@ typedef struct LineartEdgeChainItem { /** For restoring position to 3d space. */ float gpos[3]; float normal[3]; - short line_type; + uint16_t line_type; char occlusion; unsigned char material_mask_bits; unsigned char intersection_mask; @@ -195,11 +187,11 @@ typedef struct LineartChainRegisterEntry { char is_left; } LineartChainRegisterEntry; -typedef struct LineartAdjacentItem { +typedef struct LineartAdjacentEdge { unsigned int v1; unsigned int v2; unsigned int e; -} LineartAdjacentItem; +} LineartAdjacentEdge; enum eLineArtTileRecursiveLimit { /* If tile gets this small, it's already much smaller than a pixel. No need to continue diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp index a8464f8ea66..06961bfdb40 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp @@ -3,14 +3,17 @@ #include "MOD_lineart.h" #include "lineart_intern.h" -static bool cmp_adjacent_items(const LineartAdjacentItem , const LineartAdjacentItem ) +static bool cmp_adjacent_items(const LineartAdjacentEdge , const LineartAdjacentEdge ) { - int a = (int)p1.v1 - (int)p2.v1; - int b = (int)p1.v2 - (int)p2.v2; + int a = p1.v1 - p2.v1; + int b = p1.v2 - p2.v2; + /* parallel_sort() requires cmp() to return true when the first element needs to appear before + * the second element in the sorted array, false otherwise (strict weak ordering), see + * https://en.cppreference.com/w/cpp/named_req/Compare. */ return a < 0 ? true : (a == 0 ? b < 0 : false); } -void lineart_sort_adjacent_items(LineartAdjacentItem *ai, int length) +void lineart_sort_adjacent_items(LineartAdjacentEdge *ai, int length) { blender::parallel_sort(ai, ai + length - 1, cmp_adjacent_items); } diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 4995aab05ea..519a8098be2 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1503,41 +1503,13 @@ typedef struct EdgeFeatData { int freestyle_face_index; bool use_freestyle_edge; int freestyle_edge_index; - LineartEdgeNeighbor *en; + LineartEdgeNeighbor *edge_nabr; } EdgeFeatData; typedef struct EdgeFeatReduceData { int feat_edges; } EdgeFeatReduceData; -typedef struct L
[Bf-blender-cvs] [1be25a44b52] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: 1be25a44b52786379726cf880f2b23dc3ad6fa3d Author: YimingWu Date: Sat May 7 21:00:54 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB1be25a44b52786379726cf880f2b23dc3ad6fa3d Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ce63f7a5abd] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: ce63f7a5abd1d9ab05a51ac1f031887a978d79c1 Author: YimingWu Date: Wed May 4 22:30:33 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBce63f7a5abd1d9ab05a51ac1f031887a978d79c1 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1a5f2233b65] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: 1a5f2233b656b2ee132cd32604734fb5b6656b56 Author: YimingWu Date: Wed May 4 22:33:39 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB1a5f2233b656b2ee132cd32604734fb5b6656b56 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08daeb94721] master: LineArt: Clean up file name and license.
Commit: 08daeb947218caa3ffc68e7803621bfbc5fb0145 Author: YimingWu Date: Wed May 4 22:32:50 2022 +0800 Branches: master https://developer.blender.org/rB08daeb947218caa3ffc68e7803621bfbc5fb0145 LineArt: Clean up file name and license. lineart_cpp_bridge.cpp changed to .cc === M source/blender/gpencil_modifiers/CMakeLists.txt R088source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 3b6f00b56d8..2a0015cd477 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -68,7 +68,7 @@ set(SRC intern/lineart/lineart_cpu.c intern/lineart/lineart_ops.c intern/lineart/lineart_util.c - intern/lineart/lineart_cpp_bridge.cpp + intern/lineart/lineart_cpp_bridge.cc intern/lineart/MOD_lineart.h intern/lineart/lineart_intern.h diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc similarity index 88% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp rename to source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc index 06961bfdb40..174399618a5 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cc @@ -1,3 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup modifiers + */ + #include "BLI_sort.hh" #include "BLI_vector.hh" #include "MOD_lineart.h" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [03aba8046e0] master: LineArt: Object loading optimization
Commit: 03aba8046e07d956e43073502383579b7dfbb284 Author: YimingWu Date: Mon Mar 28 13:34:17 2022 +0800 Branches: master https://developer.blender.org/rB03aba8046e07d956e43073502383579b7dfbb284 LineArt: Object loading optimization This patch replaces BMesh conversion into index-based triangle adjacent lookup method, and use multithread in many steps to speed up object loading for line art. Differential Revision: https://developer.blender.org/D14627 Reviewed By: Sebastian Parborg (zeddb) === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h A source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 6108629183c..3b6f00b56d8 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -68,12 +68,29 @@ set(SRC intern/lineart/lineart_cpu.c intern/lineart/lineart_ops.c intern/lineart/lineart_util.c + intern/lineart/lineart_cpp_bridge.cpp intern/lineart/MOD_lineart.h intern/lineart/lineart_intern.h ) +if(WITH_TBB) +add_definitions(-DWITH_TBB) +if(WIN32) + # TBB includes Windows.h which will define min/max macros + # that will collide with the stl versions. + add_definitions(-DNOMINMAX) +endif() +list(APPEND INC_SYS + ${TBB_INCLUDE_DIRS} +) + +list(APPEND LIB + ${TBB_LIBRARIES} +) +endif() + set(LIB ) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 1058f861be3..0e7df2a136d 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -387,7 +387,6 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_remove_doubles", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE); uiItemR(col, ptr, "use_object_instances", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE); diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 5d952991cf7..99107a96cfe 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -132,7 +132,7 @@ typedef struct LineartEdge { char min_occ; /** Also for line type determination on chaining. */ - unsigned char flags; + uint16_t flags; unsigned char intersection_mask; /** @@ -171,7 +171,7 @@ typedef struct LineartEdgeChainItem { /** For restoring position to 3d space. */ float gpos[3]; float normal[3]; - unsigned char line_type; + uint16_t line_type; char occlusion; unsigned char material_mask_bits; unsigned char intersection_mask; @@ -189,6 +189,12 @@ typedef struct LineartChainRegisterEntry { char is_left; } LineartChainRegisterEntry; +typedef struct LineartAdjacentEdge { + unsigned int v1; + unsigned int v2; + unsigned int e; +} LineartAdjacentEdge; + enum eLineArtTileRecursiveLimit { /* If tile gets this small, it's already much smaller than a pixel. No need to continue * splitting. */ @@ -396,7 +402,7 @@ typedef struct LineartObjectInfo { typedef struct LineartObjectLoadTaskInfo { struct LineartRenderBuffer *rb; - struct Depsgraph *dg; + int thread_id; /* LinkNode styled list */ LineartObjectInfo *pending; /* Used to spread the load across several threads. This can not overflow. */ diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp new file mode 100644 index 000..06961bfdb40 --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp @@ -0,0 +1,19 @@ +#include "BLI_sort.hh" +#include "BLI_vector.hh" +#include "MOD_lineart.h" +#include "lineart_intern.h" + +static bool cmp_adjacent_items(const LineartAdjacentEdge , const LineartAdjacentEdge ) +{ + int a = p1.v1 - p2.v1; + int b = p1.v2 - p2.v2; + /* parallel_sort() requires cmp() to return true when the first element needs t
[Bf-blender-cvs] [502c420170b] lineart-shadow: LineArt: Fix light/shade cutting for intersections
Commit: 502c420170b7f130e01cb9f1e618ab0f10d2a273 Author: YimingWu Date: Tue May 3 11:00:18 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB502c420170b7f130e01cb9f1e618ab0f10d2a273 LineArt: Fix light/shade cutting for intersections === 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 a2c619eadcd..c1eec27d914 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -80,6 +80,7 @@ typedef enum eLineArtElementNodeFlag { LRT_ELEMENT_IS_ADDITIONAL = (1 << 0), LRT_ELEMENT_BORDER_ONLY = (1 << 1), LRT_ELEMENT_NO_INTERSECTION = (1 << 2), + LRT_ELEMENT_INTERSECTION_DATA = (1 << 3), } eLineArtElementNodeFlag; typedef struct LineartElementLinkNode { diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 33dbcefd5ed..0cfd3892489 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2006,6 +2006,38 @@ static void lineart_register_shadow_cuts(LineartRenderBuffer *rb, } } +static void lineart_register_intersection_shadow_cuts(LineartRenderBuffer *rb, + ListBase *shadow_elns) +{ + LineartElementLinkNode *eln_isect_shadow = NULL, *eln_isect_original = NULL; + if (!shadow_elns) { +return; + } + LISTBASE_FOREACH (LineartElementLinkNode *, eln, shadow_elns) { +if (eln->flags & LRT_ELEMENT_INTERSECTION_DATA) { + eln_isect_shadow = eln; + break; +} + } + LISTBASE_FOREACH (LineartElementLinkNode *, eln, >line_buffer_pointers) { +if (eln->flags & LRT_ELEMENT_INTERSECTION_DATA) { + eln_isect_original = eln; + break; +} + } + if (!eln_isect_shadow || !eln_isect_original) { +return; + } + LineartEdge *e = (LineartEdge *)eln_isect_original->pointer; + for (int i = 0; i < eln_isect_original->element_count; i++) { +LineartEdge *shadow_e = lineart_find_matching_edge(eln_isect_shadow, (uint64_t)e->from_shadow); +if (shadow_e) { + lineart_register_shadow_cuts(rb, e, shadow_e); +} +e++; + } +} + static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, LineartRenderBuffer *re_buf, ListBase *shadow_elns) @@ -,6 +4476,7 @@ static void lineart_create_edges_from_isec_data(LineartIsecData *d) double ZMax = rb->far_clip; double ZMin = rb->near_clip; + int total_lines = 0; for (int i = 0; i < d->thread_count; i++) { LineartIsecThread *th = >threads[i]; if (G.debug_value == 4000) { @@ -4452,13 +4485,32 @@ static void lineart_create_edges_from_isec_data(LineartIsecData *d) if (!th->current) { continue; } -/* We don't care about removing duplicated vert in this method, chaning can handle that, - * and it saves us from using locks and look up tables. */ -LineartVert *v = lineart_mem_acquire(>render_data_pool, - sizeof(LineartVert) * th->current * 2); -LineartEdge *e = lineart_mem_acquire(>render_data_pool, sizeof(LineartEdge) * th->current); -LineartEdgeSegment *es = lineart_mem_acquire(>render_data_pool, - sizeof(LineartEdgeSegment) * th->current); +total_lines += th->current; + } + + if (!total_lines) { +return; + } + + /* We don't care about removing duplicated vert in this method, chaning can handle that, + * and it saves us from using locks and look up tables. */ + LineartVert *v = lineart_mem_acquire(rb->edge_data_pool, sizeof(LineartVert) * total_lines * 2); + LineartEdge *e = lineart_mem_acquire(rb->edge_data_pool, sizeof(LineartEdge) * total_lines); + LineartEdgeSegment *es = lineart_mem_acquire(rb->edge_data_pool, + sizeof(LineartEdgeSegment) * total_lines); + + LineartElementLinkNode *eln = lineart_mem_acquire(rb->edge_data_pool, + sizeof(LineartElementLinkNode)); + eln->element_count = total_lines; + eln->pointer = e; + eln->flags |= LRT_ELEMENT_INTERSECTION_DATA; + BLI_addhead(>line_buffer_pointers, eln); + + for (int i = 0; i < d->thread_count; i++) { +LineartIsecThread *th = >threads[i]; +if (!th->cu
[Bf-blender-cvs] [0ebc0626042] lineart-object-load: LineArt: Edge neighbor with object loading code WIP
Commit: 0ebc0626042cb70ff97082ef2c40a95b50a0a68e Author: YimingWu Date: Mon Apr 25 14:54:07 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB0ebc0626042cb70ff97082ef2c40a95b50a0a68e LineArt: Edge neighbor with object loading code WIP === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index dd08fc6493f..88ac80e153f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1514,7 +1514,6 @@ typedef struct EdgeFeatData { LineartRenderBuffer *rb; Mesh *me; const MLoopTri *mlooptri; - EdgeFacePair *edge_pair_arr; LineartTriangle *tri_array; LineartVert *v_array; float crease_threshold; @@ -1522,6 +1521,7 @@ typedef struct EdgeFeatData { bool use_auto_smooth; bool use_freestyle_face; int freestyle_face_index; + LineartEdgeNeighbor *en; } EdgeFeatData; typedef struct EdgeFeatReduceData { @@ -1537,18 +1537,22 @@ static void feat_data_sum_reduce(const void *__restrict UNUSED(userdata), feat_chunk_join->feat_edges += feat_chunk->feat_edges; } -static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, -const int i, -const TaskParallelTLS *__restrict tls) +__attribute__((optimize("O0"))) static void lineart_identify_mlooptri_feature_edges( +void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls) { EdgeFeatData *e_feat_data = (EdgeFeatData *)userdata; - EdgeFacePair *e_f_pair = _feat_data->edge_pair_arr[i]; EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk; Mesh *me = e_feat_data->me; + LineartEdgeNeighbor *en = e_feat_data->en; const MLoopTri *mlooptri = e_feat_data->mlooptri; uint16_t edge_flag_result = 0; + /* Only add one from two pairs of mlooptri edges. */ + if (i < en[i].e) { +return; + } + FreestyleEdge *fel, *fer; bool face_mark_filtered = false; bool enable_face_mark = (e_feat_data->use_freestyle_face && e_feat_data->rb->filter_face_mark); @@ -1556,10 +1560,10 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, if (enable_face_mark) { int index = e_feat_data->freestyle_face_index; if (index > -1) { - fel = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[e_f_pair->f1].poly]; + fel = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[i / 3].poly]; } -if (e_f_pair->f2 != -1) { - fer = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[e_f_pair->f2].poly]; +if (en[i].e > -1) { + fer = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[en[i].e / 3].poly]; } else { /* Handles mesh boundary case */ @@ -1579,7 +1583,7 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, face_mark_filtered = !face_mark_filtered; } if (!face_mark_filtered) { - e_f_pair->eflag = LRT_EDGE_FLAG_INHIBIT; + en[i].flags = LRT_EDGE_FLAG_INHIBIT; if (e_feat_data->rb->filter_face_mark_keep_contour) { only_contour = true; } @@ -1592,8 +1596,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, else { /* Mesh boundary */ -if (e_f_pair->f2 == -1) { - e_f_pair->eflag = LRT_EDGE_FLAG_CONTOUR; +if (en[i].e == -1) { + en[i].flags = LRT_EDGE_FLAG_CONTOUR; reduce_data->feat_edges += 1; return; } @@ -1602,11 +1606,13 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, LineartVert *vert; LineartRenderBuffer *rb = e_feat_data->rb; +int f1 = i / 3, f2 = en[i].e / 3; + /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ -tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f1); -tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f2); +tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f1); +tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, f2); -vert = _feat_data->v_array[e_f_pair->v1]; +vert = _feat_data->v_array[en[i].v1]; double vv[3]; double *view_vector = vv; @@ -1632,8 +1638,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, if (rb->use_crease) { bool do_crease = true; if (!rb->force_crease &&
[Bf-blender-cvs] [5ba3e6001fe] lineart-object-load: LineArt: Try using sort/parallel_sort but crashes
Commit: 5ba3e6001fe046b432b4c3aa0e321471e70ad626 Author: YimingWu Date: Mon Apr 25 16:56:06 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB5ba3e6001fe046b432b4c3aa0e321471e70ad626 LineArt: Try using sort/parallel_sort but crashes === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h A source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 6108629183c..3b6f00b56d8 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -68,12 +68,29 @@ set(SRC intern/lineart/lineart_cpu.c intern/lineart/lineart_ops.c intern/lineart/lineart_util.c + intern/lineart/lineart_cpp_bridge.cpp intern/lineart/MOD_lineart.h intern/lineart/lineart_intern.h ) +if(WITH_TBB) +add_definitions(-DWITH_TBB) +if(WIN32) + # TBB includes Windows.h which will define min/max macros + # that will collide with the stl versions. + add_definitions(-DNOMINMAX) +endif() +list(APPEND INC_SYS + ${TBB_INCLUDE_DIRS} +) + +list(APPEND LIB + ${TBB_LIBRARIES} +) +endif() + set(LIB ) diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 830066ac0fb..a30ec4490cf 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -197,6 +197,12 @@ typedef struct LineartChainRegisterEntry { char is_left; } LineartChainRegisterEntry; +typedef struct LineartAdjacentItem { + unsigned int v1; + unsigned int v2; + unsigned int e; +} LineartAdjacentItem; + enum eLineArtTileRecursiveLimit { /* If tile gets this small, it's already much smaller than a pixel. No need to continue * splitting. */ diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp new file mode 100644 index 000..2a630e69665 --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpp_bridge.cpp @@ -0,0 +1,28 @@ +#include "BLI_sort.hh" +#include "BLI_vector.hh" +#include "MOD_lineart.h" +#include "lineart_intern.h" + +static int cmp_adjacent_items(const LineartAdjacentItem , const LineartAdjacentItem ) +{ + int a = (int)p1.v1 - (int)p2.v1; + int b = (int)p1.v2 - (int)p2.v2; + return a ? a : b; +} + +void lineart_sort_adjacent_items(LineartAdjacentItem *ai, int length) +{ + blender::Vector _ai; + _ai.reserve(length); + for (int i = 0; i < length; i++) { +_ai[i] = ai[i]; +printf("(%d %d %d)", _ai[i].v1, _ai[i].v2, _ai[i].e); + } + _ai.resize(length); + printf("\n"); + std::sort(ai, ai + length, cmp_adjacent_items); + for (int i = 0; i < length; i++) { +ai[i] = _ai[i]; +printf("(%d %d %d)", _ai[i].v1, _ai[i].v2, _ai[i].e); + } +} diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 88ac80e153f..b6639f80f63 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1452,12 +1452,6 @@ static void lineart_vert_transform_me( mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); } -typedef struct LineartAdjacentItem { - unsigned int v1; - unsigned int v2; - unsigned int e; -} LineartAdjacentItem; - typedef struct LineartEdgeNeighbor { int e; short flags; @@ -1517,7 +1511,6 @@ typedef struct EdgeFeatData { LineartTriangle *tri_array; LineartVert *v_array; float crease_threshold; - float **poly_normals; bool use_auto_smooth; bool use_freestyle_face; int freestyle_face_index; @@ -1537,8 +1530,9 @@ static void feat_data_sum_reduce(const void *__restrict UNUSED(userdata), feat_chunk_join->feat_edges += feat_chunk->feat_edges; } -__attribute__((optimize("O0"))) static void lineart_identify_mlooptri_feature_edges( -void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls) +static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, +const int i, +const TaskParallelTLS *__restrict tls) { EdgeFeatData *e_feat_data = (EdgeFeatData *)userdata; EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userd
[Bf-blender-cvs] [a3b38c979aa] lineart-object-load: Revert "LineArt: CAS-inspired tile tree (WIP)"
Commit: a3b38c979aab0d355b02533bbac47fb80ec14bd8 Author: YimingWu Date: Mon Apr 25 12:49:25 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rBa3b38c979aab0d355b02533bbac47fb80ec14bd8 Revert "LineArt: CAS-inspired tile tree (WIP)" This reverts commit 77afe859a0fecb3b03b9879a4d7419f991dc9f81. === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 85b9b64332e..6108629183c 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,7 +17,6 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc - ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index d4d39c84c51..830066ac0fb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -222,11 +222,8 @@ typedef struct LineartRenderBuffer { float overscan; - struct LineartBoundingArea **initial_bounding_areas; - unsigned int bounding_area_initial_count; - - /* Array of thread_count length for spatial locks. */ - SpinLock *lock_bounding_areas; + struct LineartBoundingArea *initial_bounding_areas; + unsigned int bounding_area_count; /* When splitting bounding areas, if there's an ortho camera placed at a straight angle, there * will be a lot of triangles aligned in line which can not be separated by continue subdividing @@ -443,7 +440,7 @@ typedef struct LineartBoundingArea { double cx, cy; /** 1,2,3,4 quadrant */ - struct LineartBoundingArea *child[4]; + struct LineartBoundingArea *child; ListBase lp; ListBase rp; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 5aa8085b0f3..b666eb677eb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -459,25 +459,25 @@ static LineartBoundingArea *lineart_bounding_area_get_eci_recursive(LineartRende LineartBoundingArea *root, LineartEdgeChainItem *eci) { - if (root->child[0] == NULL) { + if (root->child == NULL) { return root; } - LineartBoundingArea **ch = root->child; + LineartBoundingArea *ch = root->child; #define IN_BOUND(ba, eci) \ - ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] + ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] if (IN_BOUND(ch[0], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[0], eci); +return lineart_bounding_area_get_eci_recursive(rb, [0], eci); } if (IN_BOUND(ch[1], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[1], eci); +return lineart_bounding_area_get_eci_recursive(rb, [1], eci); } if (IN_BOUND(ch[2], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[2], eci); +return lineart_bounding_area_get_eci_recursive(rb, [2], eci); } if (IN_BOUND(ch[3], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[3], eci); +return lineart_bounding_area_get_eci_recursive(rb, [3], eci); } #undef IN_BOUND return NULL; @@ -507,7 +507,7 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, LineartEdgeChain *ec, LineartEdgeChainItem *eci) { - if (root->child[0] == NULL) { + if (root->child == NULL) { LineartChainRegisterEntry *cre = lineart_list_append_pointer_pool_sized( >linked_chains, >render_data_pool, ec, sizeof(LineartChainRegisterEntry)); @@ -518,22 +518,22 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, } } else { -LineartBoundingArea **ch = root->child; +LineartBoundingArea *ch = root->child; #define IN_BOUND(ba, eci) \ - ba->l <= eci->pos[0] &&a
[Bf-blender-cvs] [77afe859a0f] lineart-object-load: LineArt: CAS-inspired tile tree (WIP)
Commit: 77afe859a0fecb3b03b9879a4d7419f991dc9f81 Author: YimingWu Date: Fri Apr 15 22:10:11 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB77afe859a0fecb3b03b9879a4d7419f991dc9f81 LineArt: CAS-inspired tile tree (WIP) === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 6108629183c..85b9b64332e 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,6 +17,7 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc + ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 830066ac0fb..d4d39c84c51 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -222,8 +222,11 @@ typedef struct LineartRenderBuffer { float overscan; - struct LineartBoundingArea *initial_bounding_areas; - unsigned int bounding_area_count; + struct LineartBoundingArea **initial_bounding_areas; + unsigned int bounding_area_initial_count; + + /* Array of thread_count length for spatial locks. */ + SpinLock *lock_bounding_areas; /* When splitting bounding areas, if there's an ortho camera placed at a straight angle, there * will be a lot of triangles aligned in line which can not be separated by continue subdividing @@ -440,7 +443,7 @@ typedef struct LineartBoundingArea { double cx, cy; /** 1,2,3,4 quadrant */ - struct LineartBoundingArea *child; + struct LineartBoundingArea *child[4]; ListBase lp; ListBase rp; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index b666eb677eb..5aa8085b0f3 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -459,25 +459,25 @@ static LineartBoundingArea *lineart_bounding_area_get_eci_recursive(LineartRende LineartBoundingArea *root, LineartEdgeChainItem *eci) { - if (root->child == NULL) { + if (root->child[0] == NULL) { return root; } - LineartBoundingArea *ch = root->child; + LineartBoundingArea **ch = root->child; #define IN_BOUND(ba, eci) \ - ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] + ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] if (IN_BOUND(ch[0], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [0], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[0], eci); } if (IN_BOUND(ch[1], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [1], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[1], eci); } if (IN_BOUND(ch[2], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [2], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[2], eci); } if (IN_BOUND(ch[3], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [3], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[3], eci); } #undef IN_BOUND return NULL; @@ -507,7 +507,7 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, LineartEdgeChain *ec, LineartEdgeChainItem *eci) { - if (root->child == NULL) { + if (root->child[0] == NULL) { LineartChainRegisterEntry *cre = lineart_list_append_pointer_pool_sized( >linked_chains, >render_data_pool, ec, sizeof(LineartChainRegisterEntry)); @@ -518,22 +518,22 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, } } else { -LineartBoundingArea *ch = root->child; +LineartBoundingArea **ch = root->child; #define IN_BOUND(ba, eci) \ - ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1
[Bf-blender-cvs] [ef008bf11af] lineart-shadow: LineArt: Fix pointer type error for MSVC
Commit: ef008bf11af84ade92a7016000b3c8c37e84147e Author: YimingWu Date: Fri Apr 22 18:16:57 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBef008bf11af84ade92a7016000b3c8c37e84147e LineArt: Fix pointer type error for MSVC === 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 88021ed0eeb..c69746040ce 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -171,6 +171,8 @@ typedef enum eLineArtVertFlags { typedef struct LineartEdge { struct LineartVert *v1, *v2; + /** These two variables are also used to specify original edge and segment during 3rd stage + * reprojection, So we can easily find out the line which results come from. */ struct LineartTriangle *t1, *t2; ListBase segments; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 249af318d32..d07131fd2af 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -5504,7 +5504,7 @@ static void lineart_shadow_create_container_array(LineartRenderBuffer *rb, BLI_addtail([i].shadow_segments, [i * 2 + 1]); if (e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { -ssc[i].e_ref = e->t1; +ssc[i].e_ref = (LineartEdge *)e->t1; ssc[i].e_ref_light_contour = e; /* Restore original edge flag. */ e->flags &= (~LRT_EDGE_FLAG_CONTOUR); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0b9c5184ef0] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
Commit: 0b9c5184ef083bf733e444f40da1cbe974a66a2f Author: YimingWu Date: Fri Apr 22 16:46:18 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB0b9c5184ef083bf733e444f40da1cbe974a66a2f Merge branch 'temp-lineart-contained' into lineart-shadow === === diff --cc source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index c69746040ce,ac3cdc43235..88021ed0eeb --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@@ -169,12 -127,11 +169,10 @@@ typedef enum eLineArtVertFlags } eLineArtVertFlags; typedef struct LineartEdge { - /** We only need link node kind of list here. */ - struct LineartEdge *next; struct LineartVert *v1, *v2; - /** These two variables are also used to specify original edge and segment during 3rd stage -* reprojection, So we can easily find out the line which results come from. */ struct LineartTriangle *t1, *t2; + ListBase segments; char min_occ; diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index f5c410e9593,d0f5086a822..249af318d32 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -5294,1016 -5098,6 +5296,1016 @@@ static LineartBoundingArea *lineart_bou return 0; } +static LineartShadowSegment *lineart_give_shadow_segment(LineartRenderBuffer *rb) +{ + BLI_spin_lock(>lock_cuts); + + /* See if there is any already allocated memory we can reuse. */ + if (rb->wasted_shadow_cuts.first) { +LineartShadowSegment *es = (LineartShadowSegment *)BLI_pophead(>wasted_shadow_cuts); +BLI_spin_unlock(>lock_cuts); +memset(es, 0, sizeof(LineartShadowSegment)); +return (LineartShadowSegment *)es; + } + BLI_spin_unlock(>lock_cuts); + + /* Otherwise allocate some new memory. */ + return (LineartShadowSegment *)lineart_mem_acquire_thread(>render_data_pool, + sizeof(LineartShadowSegment)); +} + +static void lineart_shadow_segment_slice_get(double *fbl, + double *fbr, + double *gl, + double *gr, + double at, + double at_l, + double at_r, + double *r_fb, + double *r_g) +{ + double real_at = ((at_r - at_l) == 0) ? 0 : ((at - at_l) / (at_r - at_l)); + double ga = fbl[3] * real_at / (fbr[3] * (1.0f - real_at) + fbl[3] * real_at); + interp_v3_v3v3_db(r_fb, fbl, fbr, real_at); + r_fb[3] = interpd(fbr[3], fbl[3], ga); + interp_v3_v3v3_db(r_g, gl, gr, ga); +} + +/* Returns true when a new cut is needed in the middle, otherwise `*r_new_xxx` are not touched. */ +static bool lineart_do_closest_segment(bool is_persp, + double *s1fbl, + double *s1fbr, + double *s2fbl, + double *s2fbr, + double *s1gl, + double *s1gr, + double *s2gl, + double *s2gr, + double *r_fbl, + double *r_fbr, + double *r_gl, + double *r_gr, + double *r_new_in_the_middle, + double *r_new_in_the_middle_global, + double *r_new_at, + bool *is_side_2r, + bool *use_new_ref) +{ + int side = 0; + int zid = is_persp ? 3 : 2; + /* Always use the closest point to the light camera. */ + if (s1fbl[zid] >= s2fbl[zid]) { +copy_v4_v4_db(r_fbl, s2fbl); +copy_v3_v3_db(r_gl, s2gl); +side++; + } + if (s1fbr[zid] >= s2fbr[zid]) { +copy_v4_v4_db(r_fbr, s2fbr); +copy_v3_v3_db(r_gr, s2gr); +*is_side_2r = true; +side++; + } + if (s1fbl[zid] <= s2fbl[zid]) { +copy_v4_v4_db(r_fbl, s1fbl); +copy_v3_v3_db(r_gl, s1gl); +side--; + } + if (s1fbr[zid] <= s2fbr[zid]) { +copy_v4_v4_db(r_fbr, s1fbr); +copy_v3_v3_db(r_gr, s1gr); +*is_side_2r = false; +side--; + } + + /* No need to cut in the middle, because one segment completely overla
[Bf-blender-cvs] [64355e33232] lineart-shadow: LineArt: Individual locks for each tile.
Commit: 64355e332322454dcd53227e1f90b127d4f326b5 Author: YimingWu Date: Wed Apr 20 11:02:08 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB64355e332322454dcd53227e1f90b127d4f326b5 LineArt: Individual locks for each tile. === M release/datafiles/locale M release/scripts/addons M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 716dc02ec30..245306b56bd 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 716dc02ec30c0810513f7b4adc4ae865ae50c4e6 +Subproject commit 245306b56bda2aa39af219c3dd705666363e2c54 diff --git a/release/scripts/addons b/release/scripts/addons index 22c1eb5c3d5..754d05ac7eb 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 22c1eb5c3d505d85e953c3921317856af103a2eb +Subproject commit 754d05ac7ebb78377bbe6d80068542c43d347974 diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index a9d9c11e0f3..c69746040ce 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -290,9 +290,6 @@ typedef struct LineartRenderBuffer { struct LineartBoundingArea *initial_bounding_areas; unsigned int bounding_area_initial_count; - /* Array of thread_count length for spatial locks. */ - SpinLock *lock_bounding_areas; - /* When splitting bounding areas, if there's an ortho camera placed at a straight angle, there * will be a lot of triangles aligned in line which can not be separated by continue subdividing * the tile. So we set a strict limit when using ortho camera. See eLineArtTileRecursiveLimit. */ @@ -572,7 +569,7 @@ typedef struct LineartBoundingArea { /** 1,2,3,4 quadrant */ struct LineartBoundingArea *child; - SpinLock *lock; + SpinLock lock; ListBase lp; ListBase rp; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index d96284d6b56..f5c410e9593 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3953,6 +3953,16 @@ static void lineart_main_get_view_vector(LineartRenderBuffer *rb) } } +static void lineart_end_bounding_area_recursive(LineartBoundingArea *ba) +{ + BLI_spin_end(>lock); + if (ba->child) { +for (int i = 0; i < 4; i++) { + lineart_end_bounding_area_recursive(>child[i]); +} + } +} + static void lineart_destroy_render_data_keep_init(LineartRenderBuffer *rb) { if (rb == NULL) { @@ -3969,8 +3979,14 @@ static void lineart_destroy_render_data_keep_init(LineartRenderBuffer *rb) if (rb->pending_edges.array) { MEM_freeN(rb->pending_edges.array); } + + for (int i = 0; i < rb->bounding_area_initial_count; i++) { +lineart_end_bounding_area_recursive(>initial_bounding_areas[i]); + } + lineart_mem_destroy(>render_data_pool); } + static void lineart_destroy_render_data(LineartRenderBuffer *rb) { if (rb == NULL) { @@ -3981,10 +3997,6 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb) BLI_spin_end(>lock_cuts); BLI_spin_end(>render_data_pool.lock_mem); - for (int i = 0; i < rb->bounding_area_initial_count; i++) { -BLI_spin_end(>lock_bounding_areas[i]); - } - lineart_destroy_render_data_keep_init(rb); } @@ -4189,10 +4201,8 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb) rb->bounding_area_initial_count = sp_w * sp_h; rb->initial_bounding_areas = lineart_mem_acquire( >render_data_pool, sizeof(LineartBoundingArea) * rb->bounding_area_initial_count); - rb->lock_bounding_areas = lineart_mem_acquire( - >render_data_pool, sizeof(SpinLock) * rb->bounding_area_initial_count); for (int i = 0; i < rb->bounding_area_initial_count; i++) { -BLI_spin_init(>lock_bounding_areas[i]); +BLI_spin_init(>initial_bounding_areas[i].lock); } int i_ba = 0; @@ -4220,7 +4230,7 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb) sizeof(LineartEdge *) * ba->max_line_count); /* Spatial lock assignment. */ - ba->lock = >lock_bounding_areas[i_ba % rb->bounding_area_initial_count]; + BLI_spin_init(>lock); i_ba++; /* Link adjacent ones. */ @@ -4593,7 +4603,7 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, * b
[Bf-blender-cvs] [ff29d5876f8] temp-lineart-contained: Revert "LineArt: Experimental smaller chunks on add_triangles."
Commit: ff29d5876f828fe9b94c3c40304910890c97cf44 Author: YimingWu Date: Fri Apr 22 15:05:07 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBff29d5876f828fe9b94c3c40304910890c97cf44 Revert "LineArt: Experimental smaller chunks on add_triangles." This reverts commit 962e699d340c5d75a15d740a8dd9fb471352df83. === M release/datafiles/locale M release/scripts/addons M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 11e2ea5c359..245306b56bd 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 11e2ea5c35988130f09ac10d4cbbad87ff2a7501 +Subproject commit 245306b56bda2aa39af219c3dd705666363e2c54 diff --git a/release/scripts/addons b/release/scripts/addons index a254b56d417..754d05ac7eb 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit a254b56d417a3cd6d23a29a1d45c5ac1e16f0fbe +Subproject commit 754d05ac7ebb78377bbe6d80068542c43d347974 diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index b9c9a74ac4f..ac3cdc43235 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -238,9 +238,6 @@ typedef struct LineartRenderBuffer { ListBase line_buffer_pointers; ListBase triangle_buffer_pointers; - LineartElementLinkNode *isect_scheduled_up_to; - int isect_scheduled_up_to_index; - /** This one's memory is not from main pool and is free()ed after culling stage. */ ListBase triangle_adjacent_pointers; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 23cc0b1a835..dd3d5f3f5d8 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -58,12 +58,14 @@ typedef struct LineartIsecSingle { } LineartIsecSingle; typedef struct LineartIsecThread { int thread_id; - - /* Scheduled work range. */ - LineartElementLinkNode *pending_from; - LineartElementLinkNode *pending_to; - int index_from; - int index_to; + /* Thread triangle data. */ + /* Used to roughly spread the load. */ + int count_pending; + /* An array of triangle element link nodes. */ + LineartElementLinkNode **pending_triangle_nodes; + /* Count of above array. */ + int current_pending; + int max_pending; /* Thread intersection result data. */ LineartIsecSingle *array; @@ -2727,13 +2729,13 @@ static void lineart_object_load_worker(TaskPool *__restrict UNUSED(pool), //- Print size of pending objects. //- Try to feed this with an array instead of via the pool instead of a custom list //- Assign the number of objects instead of number of threads - // printf("thread start: %d\n", olti->thread_id); + printf("thread start: %d\n", olti->thread_id); for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) { lineart_geometry_object_load_no_bmesh(obi, olti->rb); // lineart_geometry_object_load(obi, olti->rb); -// printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); +printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); } - // printf("thread end: %d\n", olti->thread_id); + printf("thread end: %d\n", olti->thread_id); } static uchar lineart_intersection_mask_check(Collection *c, Object *ob) @@ -3642,44 +3644,21 @@ static void lineart_add_isec_thread(LineartIsecThread *th, th->current++; } -#define LRT_ISECT_TRIANGLE_PER_THREAD 4096; - -static bool lineart_schedule_new_triangle_task(LineartIsecThread *th) +static void lineart_add_eln_thread(LineartIsecThread *th, LineartElementLinkNode *eln) { - LineartRenderBuffer *rb = th->rb; - int remaining = LRT_ISECT_TRIANGLE_PER_THREAD; - - BLI_spin_lock(>lock_task); - LineartElementLinkNode *eln = rb->isect_scheduled_up_to; - - if (!eln) { -BLI_spin_unlock(>lock_task); -return false; - } - - th->pending_from = eln; - th->index_from = rb->isect_scheduled_up_to_index; - - while (remaining > 0 && eln) { -int remaining_this_eln = eln->element_count - rb->isect_scheduled_up_to_index; -int added_count = MIN2(remaining, remaining_this_eln); -remaining -= added_count; -if (remaining || added_count == remaining_this_eln) { - eln = eln->next; - rb->isect_scheduled_up_to = eln; -
[Bf-blender-cvs] [129b0d545c7] temp-lineart-contained: LineArt: Experimental smaller chunks on add_triangles.
Commit: 129b0d545c7de8dab492085ba0a8a31e846d5678 Author: YimingWu Date: Fri Apr 22 15:04:12 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB129b0d545c7de8dab492085ba0a8a31e846d5678 LineArt: Experimental smaller chunks on add_triangles. === M release/datafiles/locale M release/scripts/addons M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 245306b56bd..11e2ea5c359 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 245306b56bda2aa39af219c3dd705666363e2c54 +Subproject commit 11e2ea5c35988130f09ac10d4cbbad87ff2a7501 diff --git a/release/scripts/addons b/release/scripts/addons index 754d05ac7eb..a254b56d417 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 754d05ac7ebb78377bbe6d80068542c43d347974 +Subproject commit a254b56d417a3cd6d23a29a1d45c5ac1e16f0fbe diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index ac3cdc43235..b9c9a74ac4f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -238,6 +238,9 @@ typedef struct LineartRenderBuffer { ListBase line_buffer_pointers; ListBase triangle_buffer_pointers; + LineartElementLinkNode *isect_scheduled_up_to; + int isect_scheduled_up_to_index; + /** This one's memory is not from main pool and is free()ed after culling stage. */ ListBase triangle_adjacent_pointers; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index dd3d5f3f5d8..23cc0b1a835 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -58,14 +58,12 @@ typedef struct LineartIsecSingle { } LineartIsecSingle; typedef struct LineartIsecThread { int thread_id; - /* Thread triangle data. */ - /* Used to roughly spread the load. */ - int count_pending; - /* An array of triangle element link nodes. */ - LineartElementLinkNode **pending_triangle_nodes; - /* Count of above array. */ - int current_pending; - int max_pending; + + /* Scheduled work range. */ + LineartElementLinkNode *pending_from; + LineartElementLinkNode *pending_to; + int index_from; + int index_to; /* Thread intersection result data. */ LineartIsecSingle *array; @@ -2729,13 +2727,13 @@ static void lineart_object_load_worker(TaskPool *__restrict UNUSED(pool), //- Print size of pending objects. //- Try to feed this with an array instead of via the pool instead of a custom list //- Assign the number of objects instead of number of threads - printf("thread start: %d\n", olti->thread_id); + // printf("thread start: %d\n", olti->thread_id); for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) { lineart_geometry_object_load_no_bmesh(obi, olti->rb); // lineart_geometry_object_load(obi, olti->rb); -printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); +// printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); } - printf("thread end: %d\n", olti->thread_id); + // printf("thread end: %d\n", olti->thread_id); } static uchar lineart_intersection_mask_check(Collection *c, Object *ob) @@ -3644,21 +3642,44 @@ static void lineart_add_isec_thread(LineartIsecThread *th, th->current++; } -static void lineart_add_eln_thread(LineartIsecThread *th, LineartElementLinkNode *eln) +#define LRT_ISECT_TRIANGLE_PER_THREAD 4096; + +static bool lineart_schedule_new_triangle_task(LineartIsecThread *th) { - if (th->current_pending == th->max_pending) { - -LineartElementLinkNode **new_array = MEM_mallocN( -sizeof(LineartElementLinkNode *) * th->max_pending * 2, "LineartIsecSingle"); -memcpy( -new_array, th->pending_triangle_nodes, sizeof(LineartElementLinkNode *) * th->max_pending); -th->max_pending *= 2; -MEM_freeN(th->pending_triangle_nodes); -th->pending_triangle_nodes = new_array; - } - th->pending_triangle_nodes[th->current_pending] = eln; - th->count_pending += eln->element_count; - th->current_pending++; + LineartRenderBuffer *rb = th->rb; + int remaining = LRT_ISECT_TRIANGLE_PER_THREAD; + + BLI_spin_lock(>lock_task); + LineartElementLinkNode *eln = rb->isect_scheduled_up_to; + + if (!eln)
[Bf-blender-cvs] [73bf98912a0] temp-lineart-contained: Revert "LineArt: Alternating triangle adding direction"
Commit: 73bf98912a056f81fb68695de825b7b72f1b313b Author: YimingWu Date: Fri Apr 22 16:41:36 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB73bf98912a056f81fb68695de825b7b72f1b313b Revert "LineArt: Alternating triangle adding direction" Doesn't really have much performance impact thus reverting. This reverts commit c151c54a586ed8f51a050de73cb6fcd190e54ec6. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index dd3d5f3f5d8..d0f5086a822 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -4715,7 +4715,6 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line int x1, x2, y1, y2; int r, co; LineartRenderBuffer *rb = th->rb; -int _dir_control = 0; for (i = 0; i < lim; i++) { if ((tri->flags & LRT_CULL_USED) || (tri->flags & LRT_CULL_DISCARD)) { @@ -4723,26 +4722,17 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line continue; } if (lineart_get_triangle_bounding_areas(rb, tri, , , , )) { -_dir_control++; for (co = x1; co <= x2; co++) { for (r = y1; r <= y2; r++) { -int col = co, row = r; -if (_dir_control % 2) { - col = x2 - (co - x1); -} -if ((_dir_control / 2) % 2) { - row = y2 - (r - y1); -} -lineart_bounding_area_link_triangle( -rb, ->initial_bounding_areas[row * LRT_BA_ROWS + col], -tri, -0, -1, -0, -(!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)), -true, -th); +lineart_bounding_area_link_triangle(rb, +>initial_bounding_areas[r * LRT_BA_ROWS + co], +tri, +0, +1, +0, +(!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)), +true, +th); } } } /* Else throw away. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [164b5ce0949] temp-lineart-contained: LineArt: Fix tile lock assigning, now not locking the entire hierachy.
Commit: 164b5ce09497fba895f472945dddc120bf738174 Author: YimingWu Date: Fri Apr 22 15:59:44 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB164b5ce09497fba895f472945dddc120bf738174 LineArt: Fix tile lock assigning, now not locking the entire hierachy. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 5d1c8111b88..d0f5086a822 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -4304,7 +4304,7 @@ static void lineart_bounding_area_split(LineartRenderBuffer *rb, >render_data_pool, sizeof(LineartTriangle *) * LRT_TILE_SPLITTING_TRIANGLE_LIMIT); ba[i].linked_lines = lineart_mem_acquire_thread( >render_data_pool, sizeof(LineartEdge *) * LRT_TILE_EDGE_COUNT_INITIAL); -ba[i].lock = root->lock; +BLI_spin_init([i].lock); } for (int i = 0; i < root->triangle_count; i++) { @@ -4449,8 +4449,14 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, if (recursive && do_intersection && rb->use_intersections) { lineart_triangle_intersect_in_bounding_area(rb, tri, root_ba, th); } +if (do_lock) { + BLI_spin_unlock(_ba->lock); +} } else { +if (do_lock) { + BLI_spin_unlock(_ba->lock); +} LineartBoundingArea *ba = root_ba->child; double *B1 = LRUB; double b[4]; @@ -4463,25 +4469,21 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, } if (LRT_BOUND_AREA_CROSSES(B1, [0].l)) { lineart_bounding_area_link_triangle( - rb, [0], tri, B1, recursive, recursive_level + 1, do_intersection, false, th); + rb, [0], tri, B1, recursive, recursive_level + 1, do_intersection, true, th); } if (LRT_BOUND_AREA_CROSSES(B1, [1].l)) { lineart_bounding_area_link_triangle( - rb, [1], tri, B1, recursive, recursive_level + 1, do_intersection, false, th); + rb, [1], tri, B1, recursive, recursive_level + 1, do_intersection, true, th); } if (LRT_BOUND_AREA_CROSSES(B1, [2].l)) { lineart_bounding_area_link_triangle( - rb, [2], tri, B1, recursive, recursive_level + 1, do_intersection, false, th); + rb, [2], tri, B1, recursive, recursive_level + 1, do_intersection, true, th); } if (LRT_BOUND_AREA_CROSSES(B1, [3].l)) { lineart_bounding_area_link_triangle( - rb, [3], tri, B1, recursive, recursive_level + 1, do_intersection, false, th); + rb, [3], tri, B1, recursive, recursive_level + 1, do_intersection, true, th); } } - - if (do_lock) { -BLI_spin_unlock(_ba->lock); - } } static void lineart_bounding_area_link_edge(LineartRenderBuffer *rb, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c151c54a586] temp-lineart-contained: LineArt: Alternating triangle adding direction
Commit: c151c54a586ed8f51a050de73cb6fcd190e54ec6 Author: YimingWu Date: Fri Apr 22 16:00:45 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBc151c54a586ed8f51a050de73cb6fcd190e54ec6 LineArt: Alternating triangle adding direction === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index d0f5086a822..dd3d5f3f5d8 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -4715,6 +4715,7 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line int x1, x2, y1, y2; int r, co; LineartRenderBuffer *rb = th->rb; +int _dir_control = 0; for (i = 0; i < lim; i++) { if ((tri->flags & LRT_CULL_USED) || (tri->flags & LRT_CULL_DISCARD)) { @@ -4722,17 +4723,26 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line continue; } if (lineart_get_triangle_bounding_areas(rb, tri, , , , )) { +_dir_control++; for (co = x1; co <= x2; co++) { for (r = y1; r <= y2; r++) { -lineart_bounding_area_link_triangle(rb, ->initial_bounding_areas[r * LRT_BA_ROWS + co], -tri, -0, -1, -0, -(!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)), -true, -th); +int col = co, row = r; +if (_dir_control % 2) { + col = x2 - (co - x1); +} +if ((_dir_control / 2) % 2) { + row = y2 - (r - y1); +} +lineart_bounding_area_link_triangle( +rb, +>initial_bounding_areas[row * LRT_BA_ROWS + col], +tri, +0, +1, +0, +(!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)), +true, +th); } } } /* Else throw away. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [58511c4175f] lineart-object-load: LineArt: Face mark filtering for new object loading code.
Commit: 58511c4175f6a505d53034809010db60e335401c Author: YimingWu Date: Thu Apr 7 09:07:55 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB58511c4175f6a505d53034809010db60e335401c LineArt: Face mark filtering for new object loading code. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_lineart_types.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index afcde2c3a7f..3419fa4e224 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1498,6 +1498,8 @@ typedef struct EdgeFeatData { float crease_threshold; float **poly_normals; bool use_auto_smooth; + bool use_freestyle_face; + int freestyle_face_index; } EdgeFeatData; typedef struct EdgeFeatReduceData { @@ -1520,127 +1522,151 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, EdgeFeatData *e_feat_data = (EdgeFeatData *)userdata; EdgeFacePair *e_f_pair = _feat_data->edge_pair_arr[i]; EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk; - /* Mesh boundary */ - if (e_f_pair->f2 == -1) { -e_f_pair->eflag = LRT_EDGE_FLAG_CONTOUR; -reduce_data->feat_edges += 1; + Mesh *me = e_feat_data->me; + const MLoopTri *mlooptri = e_feat_data->mlooptri; + + uint16_t edge_flag_result = 0; + + FreestyleEdge *fel, *fer; + bool face_mark_filtered = false; + bool enable_face_mark = (e_feat_data->use_freestyle_face && e_feat_data->rb->filter_face_mark); + bool only_contour = false; + if (enable_face_mark) { +int index = e_feat_data->freestyle_face_index; +if (index > -1) { + fel = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[e_f_pair->f1].poly]; +} +if (e_f_pair->f2 != -1) { + fer = &((FreestyleEdge *)me->pdata.layers[index].data)[mlooptri[e_f_pair->f2].poly]; +} +else { + /* Handles mesh boundary case */ + fer = fel; +} +if (e_feat_data->rb->filter_face_mark_boundaries ^ e_feat_data->rb->filter_face_mark_invert) { + if ((fel->flag & FREESTYLE_FACE_MARK) || (fer->flag & FREESTYLE_FACE_MARK)) { +face_mark_filtered = true; + } +} +else { + if ((fel->flag & FREESTYLE_FACE_MARK) && (fer->flag & FREESTYLE_FACE_MARK) && (fer != fel)) { +face_mark_filtered = true; + } +} +if (e_feat_data->rb->filter_face_mark_invert) { + face_mark_filtered = !face_mark_filtered; +} +if (!face_mark_filtered) { + e_f_pair->eflag = LRT_EDGE_FLAG_INHIBIT; + if (e_feat_data->rb->filter_face_mark_keep_contour) { +only_contour = true; + } +} + } + + if (enable_face_mark && !face_mark_filtered && !only_contour) { return; } + else { - LineartTriangle *tri1, *tri2; - LineartVert *vert; - LineartRenderBuffer *rb = e_feat_data->rb; +/* Mesh boundary */ +if (e_f_pair->f2 == -1) { + e_f_pair->eflag = LRT_EDGE_FLAG_CONTOUR; + reduce_data->feat_edges += 1; + return; +} - /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ - tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f1); - tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f2); +LineartTriangle *tri1, *tri2; +LineartVert *vert; +LineartRenderBuffer *rb = e_feat_data->rb; - vert = _feat_data->v_array[e_f_pair->v1]; +/* The mesh should already be triangulated now, so we can assume each face is a triangle. */ +tri1 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f1); +tri2 = lineart_triangle_from_index(rb, e_feat_data->tri_array, e_f_pair->f2); - double vv[3]; - double *view_vector = vv; - double dot_1 = 0, dot_2 = 0; - double result; +vert = _feat_data->v_array[e_f_pair->v1]; - if (rb->cam_is_persp) { -sub_v3_v3v3_db(view_vector, vert->gloc, rb->camera_pos); - } - else { -view_vector = rb->view_vector; - } +double vv[3]; +double *view_vector = vv; +double dot_1 = 0, dot_2 = 0; +double result; - dot_1 = dot_v3v3_db(view_vector, tri1->gn); - dot_2 = dot_v3v3_db(view_vector, tri2->gn); - uint16_t edge_flag_result = 0; +if (rb->cam_is_persp) { + sub_v3_v3v3_db(view_vector, vert->gloc, rb->camera_pos); +} +else { + view_vector = rb->view_vector; +} - if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { -ed
[Bf-blender-cvs] [ce689964a4b] lineart-object-load: LineArt: Index calculation based adjacent lookup WIP
Commit: ce689964a4b3d3604b252bcfb3cf50297be3ff23 Author: YimingWu Date: Wed Apr 20 10:53:21 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rBce689964a4b3d3604b252bcfb3cf50297be3ff23 LineArt: Index calculation based adjacent lookup WIP === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index acc36062152..dd08fc6493f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1429,6 +1429,41 @@ static void lineart_main_discard_out_of_frame_edges(LineartRenderBuffer *rb) } } +/** + * Transform a single vert to it's viewing position. + */ +static void lineart_vert_transform( +BMVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4]) +{ + double co[4]; + LineartVert *vt = [index]; + copy_v3db_v3fl(co, v->co); + mul_v3_m4v3_db(vt->gloc, mv_mat, co); + mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); +} + +static void lineart_vert_transform_me( +MVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4]) +{ + double co[4]; + LineartVert *vt = [index]; + copy_v3db_v3fl(co, v->co); + mul_v3_m4v3_db(vt->gloc, mv_mat, co); + mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); +} + +typedef struct LineartAdjacentItem { + unsigned int v1; + unsigned int v2; + unsigned int e; +} LineartAdjacentItem; + +typedef struct LineartEdgeNeighbor { + int e; + short flags; + int v1, v2; +} LineartEdgeNeighbor; + typedef struct VertData { MVert *mvert; LineartVert *v_arr; @@ -1657,6 +1692,146 @@ static uint16_t lineart_identify_medge_feature_edges( return edge_flag_result; } +__attribute__((optimize("O0"))) static uint16_t lineart_identify_feature_line_me( +LineartRenderBuffer *rb, +int eindex, +LineartTriangle *rt_array, +LineartVert *rv_array, +float crease_threshold, +bool use_auto_smooth, +bool use_freestyle_edge, +bool use_freestyle_face, +Mesh *me, +LineartEdgeNeighbor *en, +float (*normals)[3]) +{ + + MPoly *ll = NULL, *lr = NULL; + + int t1i = -1, t1e = -1, t2i = -1; + if (en[eindex].e >= 0) { +t1i = en[eindex].e / 3; +t1e = en[eindex].e; + } + if (t1e >= 0 && en[t1e].e >= 0) { +t2i = en[t1e].e / 3; + } + + if (t1i >= 0) { +ll = >mpoly[me->runtime.looptris.array[t1i].poly]; + } + if (t2i >= 0) { +lr = >mpoly[me->runtime.looptris.array[t2i].poly]; + } + + if (t1i < 0 && t2i < 0) { +if (!rb->use_loose_as_contour) { + if (use_freestyle_face && rb->filter_face_mark) { +if (rb->filter_face_mark_invert) { + return LRT_EDGE_FLAG_LOOSE; +} +return 0; + } + return LRT_EDGE_FLAG_LOOSE; +} + } + + FreestyleEdge *fel, *fer; + bool face_mark_filtered = false; + bool only_contour = false; + + uint16_t edge_flag_result = 0; + + /* Mesh boundary */ + if (!ll || !lr) { +return (edge_flag_result | LRT_EDGE_FLAG_CONTOUR); + } + + LineartTriangle *tri1, *tri2; + LineartVert *l; + + /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ + tri1 = lineart_triangle_from_index(rb, rt_array, t1i); + tri2 = lineart_triangle_from_index(rb, rt_array, t2i); + + l = _array[en[eindex].v1]; + + double vv[3]; + double *view_vector = vv; + double dot_1 = 0, dot_2 = 0; + double result; + bool material_back_face = ((tri1->flags | tri2->flags) & LRT_TRIANGLE_MAT_BACK_FACE_CULLING); + + if (rb->use_contour || rb->use_back_face_culling || material_back_face) { + +if (rb->cam_is_persp) { + sub_v3_v3v3_db(view_vector, rb->camera_pos, l->gloc); +} +else { + view_vector = rb->view_vector; +} + +dot_1 = dot_v3v3_db(view_vector, tri1->gn); +dot_2 = dot_v3v3_db(view_vector, tri2->gn); + +if (rb->use_contour && (result = dot_1 * dot_2) <= 0 && (fabs(dot_1) + fabs(dot_2))) { + edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; +} + +/* Because the ray points towards the camera, so backface is when dot value being negative.*/ +if (rb->use_back_face_culling) { + if (dot_1 < 0) { +tri1->flags |= LRT_CULL_DISCARD; + } + if (dot_2 < 0) { +tri2->flags |= LRT_CULL_DISCARD; + } +} +if (material_back_face) { + if (tri1->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_1 < 0) { +tri1->flags |= LRT_CULL_DISCARD; + } + if (tri2->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_2 < 0) { +
[Bf-blender-cvs] [516ec45d10b] lineart-object-load: LineArt: Object loading fixes for master
Commit: 516ec45d10b867d54e614fc5c6952ead3a342d27 Author: YimingWu Date: Tue Apr 12 19:50:46 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB516ec45d10b867d54e614fc5c6952ead3a342d27 LineArt: Object loading fixes for master === M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 1058f861be3..0e7df2a136d 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -387,7 +387,6 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_remove_doubles", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE); uiItemR(col, ptr, "use_object_instances", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE); diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index a168873740a..830066ac0fb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -140,7 +140,7 @@ typedef struct LineartEdge { char min_occ; /** Also for line type determination on chaining. */ - unsigned char flags; + short flags; unsigned char intersection_mask; /** @@ -179,7 +179,7 @@ typedef struct LineartEdgeChainItem { /** For restoring position to 3d space. */ float gpos[3]; float normal[3]; - unsigned char line_type; + short line_type; char occlusion; unsigned char material_mask_bits; unsigned char intersection_mask; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 3419fa4e224..acc36062152 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1429,19 +1429,6 @@ static void lineart_main_discard_out_of_frame_edges(LineartRenderBuffer *rb) } } -/** - * Transform a single vert to it's viewing position. - */ -static void lineart_vert_transform( -BMVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4]) -{ - double co[4]; - LineartVert *vt = [index]; - copy_v3db_v3fl(co, v->co); - mul_v3_m4v3_db(vt->gloc, mv_mat, co); - mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); -} - typedef struct VertData { MVert *mvert; LineartVert *v_arr; @@ -1670,170 +1657,6 @@ static uint16_t lineart_identify_medge_feature_edges( return edge_flag_result; } -static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb, - BMEdge *e, - LineartTriangle *rt_array, - LineartVert *rv_array, - float crease_threshold, - bool use_auto_smooth, - bool use_freestyle_edge, - bool use_freestyle_face, - BMesh *bm_if_freestyle) -{ - BMLoop *ll, *lr = NULL; - - ll = e->l; - if (ll) { -lr = e->l->radial_next; - } - - if (!ll && !lr) { -return LRT_EDGE_FLAG_LOOSE; - } - - FreestyleEdge *fel, *fer; - bool face_mark_filtered = false; - uint16_t edge_flag_result = 0; - bool only_contour = false; - - if (use_freestyle_face && rb->filter_face_mark) { -fel = CustomData_bmesh_get(_if_freestyle->pdata, ll->f->head.data, CD_FREESTYLE_FACE); -if (ll != lr && lr) { - fer = CustomData_bmesh_get(_if_freestyle->pdata, lr->f->head.data, CD_FREESTYLE_FACE); -} -else { - /* Handles mesh boundary case */ - fer = fel; -} -if (rb->filter_face_mark_boundaries ^ rb->filter_face_mark_invert) { - if ((fel->flag & FREESTYLE_FACE_MARK) || (fer->flag & FREESTYLE_FACE_MARK)) { -face_mark_filtered = true; - } -} -else { - if ((fel->flag & FREESTYLE_FACE_MARK) && (fer->flag & FREESTYLE_FACE_MARK) &am
[Bf-blender-cvs] [fe2df4c771a] lineart-object-load: LineArt: Object loading wip
Commit: fe2df4c771af415ea049497590b7d1a9699abccf Author: YimingWu Date: Mon Mar 28 13:34:17 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rBfe2df4c771af415ea049497590b7d1a9699abccf LineArt: Object loading wip === M source/blender/blenlib/intern/BLI_mempool.c 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/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index f70b5ddd766..bc97b71c78e 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -355,32 +355,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) { BLI_freenode *newhead = addr; -#ifndef NDEBUG - { -BLI_mempool_chunk *chunk; -bool found = false; -for (chunk = pool->chunks; chunk; chunk = chunk->next) { - if (ARRAY_HAS_ITEM((char *)addr, (char *)CHUNK_DATA(chunk), pool->csize)) { -found = true; -break; - } -} -if (!found) { - BLI_assert_msg(0, "Attempt to free data which is not in pool.\n"); -} - } - - /* Enable for debugging. */ - if (UNLIKELY(mempool_debug_memset)) { -memset(addr, 255, pool->esize); - } -#endif - if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { -#ifndef NDEBUG -/* This will detect double free's. */ -BLI_assert(newhead->freeword != FREEWORD); -#endif newhead->freeword = FREEWORD; } diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 5d952991cf7..a168873740a 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -14,6 +14,14 @@ #include +typedef struct EdgeFacePair { + int v1; + int v2; + int f1; + int f2; + uint16_t eflag; +} EdgeFacePair; + typedef struct LineartStaticMemPoolNode { Link item; size_t size; @@ -396,7 +404,7 @@ typedef struct LineartObjectInfo { typedef struct LineartObjectLoadTaskInfo { struct LineartRenderBuffer *rb; - struct Depsgraph *dg; + int thread_id; /* LinkNode styled list */ LineartObjectInfo *pending; /* Used to spread the load across several threads. This can not overflow. */ diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 08737c19eef..981dd5105c4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -8,6 +8,7 @@ #include "MOD_gpencil_lineart.h" #include "MOD_lineart.h" +#include "BLI_edgehash.h" #include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -28,6 +29,8 @@ #include "BKE_lib_id.h" #include "BKE_material.h" #include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" +#include "BKE_mesh_runtime.h" #include "BKE_object.h" #include "BKE_pointcache.h" #include "BKE_scene.h" @@ -1439,6 +1442,39 @@ static void lineart_vert_transform( mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); } +typedef struct VertData { + MVert *mvert; + LineartVert *v_arr; + double (*model_view)[4]; + double (*model_view_proj)[4]; +} VertData; + +static void lineart_mvert_transform_task(void *__restrict userdata, + const int i, + const TaskParallelTLS *__restrict UNUSED(tls)) +{ + VertData *vert_task_data = (VertData *)userdata; + MVert *m_v = _task_data->mvert[i]; + double co[4]; + LineartVert *v = _task_data->v_arr[i]; + copy_v3db_v3fl(co, m_v->co); + mul_v3_m4v3_db(v->gloc, vert_task_data->model_view, co); + mul_v4_m4v3_db(v->fbcoord, vert_task_data->model_view_proj, co); + v->index = i; +} + +static int lineart_edge_type_duplication_count(char eflag) +{ + int count = 0; + /* See eLineartEdgeFlag for details. */ + for (int i = 0; i < 6; i++) { +if (eflag & (1 << i)) { + count++; +} + } + return count; +} + /** * Because we have a variable size for #LineartTriangle, we need an access helper. * See #LineartTriangleThread for more info. @@ -1452,6 +1488,161 @@ static LineartTriangle *lineart_triangle_from_index(LineartRenderBuffer *rb, return (LineartTriangle *)b; } +typedef struct EdgeFeatData { + LineartRenderBuffer *rb; + Mesh *me; + const MLoopTri *mlooptri; + EdgeFacePair *edge_pair_arr; + LineartTriangle *tri_array; + LineartVert *v_array; + float crease_threshold; + bool use_auto_smooth; +} EdgeFea
[Bf-blender-cvs] [f49948bf488] lineart-object-load: LineArt: Working fix for new object loading
Commit: f49948bf488139214246e782f980ef7f2c7ea6f3 Author: YimingWu Date: Tue Apr 5 22:59:13 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rBf49948bf488139214246e782f980ef7f2c7ea6f3 LineArt: Working fix for new object loading === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e54d12a650a..afcde2c3a7f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2252,6 +2252,12 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, int allocate_la_e = edge_reduce.feat_edges; + if (!edge_pair_arr) { +edge_pair_alloc_len = 256; +edge_pair_arr = MEM_mallocN(sizeof(EdgeFacePair) * edge_pair_alloc_len, +"lineart edge_pair arr"); + } + /* Check for edge marks that would create feature edges. */ for (int i = 0; i < me->totedge; i++) { MEdge *medge = >medge[i]; @@ -2261,7 +2267,7 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, if (eflag) { int min_edges_to_add = 0; void **eval; - if (!BLI_edgehash_ensure_p(edge_hash, medge->v1, medge->v2, )) { + if (edge_hash == NULL || !BLI_edgehash_ensure_p(edge_hash, medge->v1, medge->v2, )) { int pair_idx = edge_pair_arr_len++; /* Edge has not been added before, create a new pair. */ EdgeFacePair *pair = _pair_arr[pair_idx]; @@ -2271,7 +2277,9 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, pair->f1 = -1; pair->f2 = -1; pair->eflag = eflag; -*eval = POINTER_FROM_INT(pair_idx); +if (edge_hash) { + *eval = POINTER_FROM_INT(pair_idx); +} min_edges_to_add = 1; if (edge_pair_arr_len == edge_pair_alloc_len) { @@ -2301,7 +2309,9 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, } } - BLI_edgehash_free(edge_hash, NULL); + if (edge_hash) { +BLI_edgehash_free(edge_hash, NULL); + } la_edge_arr = lineart_mem_acquire_thread(_buf->render_data_pool, sizeof(LineartEdge) * allocate_la_e); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3a055e8f41d] lineart-object-load: LineArt: Crease by sharp
Commit: 3a055e8f41d18442be21a231c33f517adefc24a6 Author: YimingWu Date: Sun Apr 3 16:46:10 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB3a055e8f41d18442be21a231c33f517adefc24a6 LineArt: Crease by sharp === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c263f69ff00..0241f8f3d96 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1561,20 +1561,20 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, const MLoopTri *mlooptri = e_feat_data->mlooptri; if (rb->use_crease) { -// if (rb->sharp_as_crease && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) { -// edge_flag_result |= LRT_EDGE_FLAG_CREASE; -//} -// else { -bool do_crease = true; -if (!rb->force_crease && !e_feat_data->use_auto_smooth && -(me->mpoly[mlooptri[e_f_pair->f1].poly].flag & ME_SMOOTH) && -(me->mpoly[mlooptri[e_f_pair->f2].poly].flag & ME_SMOOTH)) { - do_crease = false; -} -if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { +if (e_f_pair->eflag & BM_ELEM_TAG) { edge_flag_result |= LRT_EDGE_FLAG_CREASE; } -//} +else { + bool do_crease = true; + if (!rb->force_crease && !e_feat_data->use_auto_smooth && + (me->mpoly[mlooptri[e_f_pair->f1].poly].flag & ME_SMOOTH) && + (me->mpoly[mlooptri[e_f_pair->f2].poly].flag & ME_SMOOTH)) { +do_crease = false; + } + if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { +edge_flag_result |= LRT_EDGE_FLAG_CREASE; + } +} } int mat1 = me->mpoly[mlooptri[e_f_pair->f1].poly].mat_nr; @@ -1608,6 +1608,10 @@ static uint16_t lineart_identify_medge_feature_edges(LineartRenderBuffer *rb, bool face_mark_filtered = false; uint16_t edge_flag_result = 0; + if (rb->use_crease && rb->sharp_as_crease && medge->flag & ME_SHARP) { +edge_flag_result |= LRT_EDGE_FLAG_CREASE; + } + // if (use_freestyle_face && rb->filter_face_mark) { // fel = CustomData_bmesh_get(_if_freestyle->pdata, ll->f->head.data, CD_FREESTYLE_FACE); // if (ll != lr && lr) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [50840bb2a3a] lineart-object-load: LineArt: Crease in new object loading working correctly.
Commit: 50840bb2a3a08cf0572681c22c030f375bf0d80a Author: YimingWu Date: Sun Apr 3 18:03:36 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB50840bb2a3a08cf0572681c22c030f375bf0d80a LineArt: Crease in new object loading working correctly. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 0241f8f3d96..e54d12a650a 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1561,19 +1561,14 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, const MLoopTri *mlooptri = e_feat_data->mlooptri; if (rb->use_crease) { -if (e_f_pair->eflag & BM_ELEM_TAG) { - edge_flag_result |= LRT_EDGE_FLAG_CREASE; +bool do_crease = true; +if (!rb->force_crease && !e_feat_data->use_auto_smooth && +(me->mpoly[mlooptri[e_f_pair->f1].poly].flag & ME_SMOOTH) && +(me->mpoly[mlooptri[e_f_pair->f2].poly].flag & ME_SMOOTH)) { + do_crease = false; } -else { - bool do_crease = true; - if (!rb->force_crease && !e_feat_data->use_auto_smooth && - (me->mpoly[mlooptri[e_f_pair->f1].poly].flag & ME_SMOOTH) && - (me->mpoly[mlooptri[e_f_pair->f2].poly].flag & ME_SMOOTH)) { -do_crease = false; - } - if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { -edge_flag_result |= LRT_EDGE_FLAG_CREASE; - } +if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { + edge_flag_result |= LRT_EDGE_FLAG_CREASE; } } @@ -1608,7 +1603,7 @@ static uint16_t lineart_identify_medge_feature_edges(LineartRenderBuffer *rb, bool face_mark_filtered = false; uint16_t edge_flag_result = 0; - if (rb->use_crease && rb->sharp_as_crease && medge->flag & ME_SHARP) { + if (rb->use_crease && rb->sharp_as_crease && (medge->flag & ME_SHARP)) { edge_flag_result |= LRT_EDGE_FLAG_CREASE; } @@ -2141,7 +2136,7 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, if (orig_ob->lineart.flags & OBJECT_LRT_OWN_CREASE) { use_crease = cosf(M_PI - orig_ob->lineart.crease_threshold); } - if (ob_info->original_me->flag & ME_AUTOSMOOTH) { + else if (ob_info->original_me->flag & ME_AUTOSMOOTH) { use_crease = cosf(ob_info->original_me->smoothresh); use_auto_smooth = true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0d5d5542873] lineart-object-load: LineArt: Crease support for new loading
Commit: 0d5d55428731c15732e107241de5b0c09d52edcb Author: YimingWu Date: Tue Apr 12 19:09:51 2022 +0800 Branches: lineart-object-load https://developer.blender.org/rB0d5d55428731c15732e107241de5b0c09d52edcb LineArt: Crease support for new loading === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 981dd5105c4..c263f69ff00 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1496,6 +1496,7 @@ typedef struct EdgeFeatData { LineartTriangle *tri_array; LineartVert *v_array; float crease_threshold; + float **poly_normals; bool use_auto_smooth; } EdgeFeatData; @@ -1556,25 +1557,26 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; } - // if (rb->use_crease) { - // if (rb->sharp_as_crease && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) { - // edge_flag_result |= LRT_EDGE_FLAG_CREASE; - // } - // else { - // bool do_crease = true; - // if (!rb->force_crease && !use_auto_smooth && - // (BM_elem_flag_test(ll->f, BM_ELEM_SMOOTH) && BM_elem_flag_test(lr->f, - // BM_ELEM_SMOOTH))) { - // do_crease = false; - // } - // if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) { - // edge_flag_result |= LRT_EDGE_FLAG_CREASE; - // } - // } - // } Mesh *me = e_feat_data->me; const MLoopTri *mlooptri = e_feat_data->mlooptri; + if (rb->use_crease) { +// if (rb->sharp_as_crease && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) { +// edge_flag_result |= LRT_EDGE_FLAG_CREASE; +//} +// else { +bool do_crease = true; +if (!rb->force_crease && !e_feat_data->use_auto_smooth && +(me->mpoly[mlooptri[e_f_pair->f1].poly].flag & ME_SMOOTH) && +(me->mpoly[mlooptri[e_f_pair->f2].poly].flag & ME_SMOOTH)) { + do_crease = false; +} +if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { + edge_flag_result |= LRT_EDGE_FLAG_CREASE; +} +//} + } + int mat1 = me->mpoly[mlooptri[e_f_pair->f1].poly].mat_nr; int mat2 = me->mpoly[mlooptri[e_f_pair->f2].poly].mat_nr; @@ -2084,6 +2086,8 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me); const int tot_tri = BKE_mesh_runtime_looptri_len(me); + // float **normals = BKE_mesh_poly_normals_ensure(me); + // TODO if (0) { MEdge *medge = NULL; @@ -2239,6 +2243,7 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, edge_feat_data.v_array = la_v_arr; edge_feat_data.crease_threshold = use_crease; edge_feat_data.use_auto_smooth = use_auto_smooth; + // edge_feat_data.poly_normals = normals; BLI_task_parallel_range(0, edge_pair_arr_len, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dbfaf575494] temp-lineart-contained: LineArt: Individual locks for each tile.
Commit: dbfaf575494f6dcca314eb4fd851d512060e9fc2 Author: YimingWu Date: Wed Apr 20 11:02:08 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBdbfaf575494f6dcca314eb4fd851d512060e9fc2 LineArt: Individual locks for each tile. === M release/datafiles/locale M release/scripts/addons M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 716dc02ec30..245306b56bd 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 716dc02ec30c0810513f7b4adc4ae865ae50c4e6 +Subproject commit 245306b56bda2aa39af219c3dd705666363e2c54 diff --git a/release/scripts/addons b/release/scripts/addons index 22c1eb5c3d5..754d05ac7eb 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 22c1eb5c3d505d85e953c3921317856af103a2eb +Subproject commit 754d05ac7ebb78377bbe6d80068542c43d347974 diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index a66412b854c..ac3cdc43235 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -229,9 +229,6 @@ typedef struct LineartRenderBuffer { struct LineartBoundingArea *initial_bounding_areas; unsigned int bounding_area_initial_count; - /* Array of thread_count length for spatial locks. */ - SpinLock *lock_bounding_areas; - /* When splitting bounding areas, if there's an ortho camera placed at a straight angle, there * will be a lot of triangles aligned in line which can not be separated by continue subdividing * the tile. So we set a strict limit when using ortho camera. See eLineArtTileRecursiveLimit. */ @@ -467,7 +464,7 @@ typedef struct LineartBoundingArea { /** 1,2,3,4 quadrant */ struct LineartBoundingArea *child; - SpinLock *lock; + SpinLock lock; ListBase lp; ListBase rp; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 2a3f7653bdb..3e19a0cad97 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3792,6 +3792,16 @@ static void lineart_main_get_view_vector(LineartRenderBuffer *rb) copy_v3db_v3fl(rb->view_vector, trans); } +static void lineart_end_bounding_area_recursive(LineartBoundingArea *ba) +{ + BLI_spin_end(>lock); + if (ba->child) { +for (int i = 0; i < 4; i++) { + lineart_end_bounding_area_recursive(>child[i]); +} + } +} + static void lineart_destroy_render_data(LineartRenderBuffer *rb) { if (rb == NULL) { @@ -3818,7 +3828,7 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb) BLI_spin_end(>render_data_pool.lock_mem); for (int i = 0; i < rb->bounding_area_initial_count; i++) { -BLI_spin_end(>lock_bounding_areas[i]); +lineart_end_bounding_area_recursive(>initial_bounding_areas[i]); } MEM_freeN(rb->pending_edges.array); @@ -4019,10 +4029,8 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb) rb->bounding_area_initial_count = sp_w * sp_h; rb->initial_bounding_areas = lineart_mem_acquire( >render_data_pool, sizeof(LineartBoundingArea) * rb->bounding_area_initial_count); - rb->lock_bounding_areas = lineart_mem_acquire( - >render_data_pool, sizeof(SpinLock) * rb->bounding_area_initial_count); for (int i = 0; i < rb->bounding_area_initial_count; i++) { -BLI_spin_init(>lock_bounding_areas[i]); +BLI_spin_init(>initial_bounding_areas[i].lock); } int i_ba = 0; @@ -4050,7 +4058,7 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb) sizeof(LineartEdge *) * ba->max_line_count); /* Spatial lock assignment. */ - ba->lock = >lock_bounding_areas[i_ba % rb->bounding_area_initial_count]; + BLI_spin_init(>lock); i_ba++; /* Link adjacent ones. */ @@ -4423,7 +4431,7 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, * bounding area r/w access for now, so whether we split or do anything inside the bounding area, * it's not relevant to other threads. */ if (do_lock) { -BLI_spin_lock(root_ba->lock); +BLI_spin_lock(_ba->lock); } if (root_ba->child == NULL) { @@ -4470,7 +4478,7 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb, } if (do_lock) { -BLI_spin_unl
[Bf-blender-cvs] [5a898d915bb] temp-lineart-contained: Revert "LineArt: Index calculation based adjacent lookup WIP"
Commit: 5a898d915bbb63813695c0bcf6c22e67c33bb648 Author: YimingWu Date: Wed Apr 20 10:53:35 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB5a898d915bbb63813695c0bcf6c22e67c33bb648 Revert "LineArt: Index calculation based adjacent lookup WIP" This reverts commit 7ef1f7648f423cc2991c7599a7b3743971fdd184. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index af82edfd0aa..2a3f7653bdb 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1450,28 +1450,6 @@ static void lineart_vert_transform( mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); } -static void lineart_vert_transform_me( -MVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4]) -{ - double co[4]; - LineartVert *vt = [index]; - copy_v3db_v3fl(co, v->co); - mul_v3_m4v3_db(vt->gloc, mv_mat, co); - mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); -} - -typedef struct LineartAdjacentItem { - unsigned int v1; - unsigned int v2; - unsigned int e; -} LineartAdjacentItem; - -typedef struct LineartEdgeNeighbor { - int e; - short flags; - int v1, v2; -} LineartEdgeNeighbor; - typedef struct VertData { MVert *mvert; LineartVert *v_arr; @@ -1700,163 +1678,6 @@ static uint16_t lineart_identify_medge_feature_edges( return edge_flag_result; } -__attribute__((optimize("O0"))) static uint16_t lineart_identify_feature_line_me( -LineartRenderBuffer *rb, -int eindex, -LineartTriangle *rt_array, -LineartVert *rv_array, -float crease_threshold, -bool use_auto_smooth, -bool use_freestyle_edge, -bool use_freestyle_face, -Mesh *me, -LineartEdgeNeighbor *en, -float (*normals)[3]) -{ - - MPoly *ll = NULL, *lr = NULL; - - int t1i = -1, t1e = -1, t2i = -1; - if (en[eindex].e >= 0) { -t1i = en[eindex].e / 3; -t1e = en[eindex].e; - } - if (t1e >= 0 && en[t1e].e >= 0) { -t2i = en[t1e].e / 3; - } - - if (t1i >= 0) { -ll = >mpoly[me->runtime.looptris.array[t1i].poly]; - } - if (t2i >= 0) { -lr = >mpoly[me->runtime.looptris.array[t2i].poly]; - } - - if (t1i < 0 && t2i < 0) { -if (!rb->use_loose_as_contour) { - if (use_freestyle_face && rb->filter_face_mark) { -if (rb->filter_face_mark_invert) { - return LRT_EDGE_FLAG_LOOSE; -} -return 0; - } - return LRT_EDGE_FLAG_LOOSE; -} - } - - FreestyleEdge *fel, *fer; - bool face_mark_filtered = false; - bool only_contour = false; - - uint16_t edge_flag_result = 0; - - /* Mesh boundary */ - if (!ll || !lr) { -return (edge_flag_result | LRT_EDGE_FLAG_CONTOUR); - } - - LineartTriangle *tri1, *tri2; - LineartVert *l; - - /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ - tri1 = lineart_triangle_from_index(rb, rt_array, t1i); - tri2 = lineart_triangle_from_index(rb, rt_array, t2i); - - l = _array[en[eindex].v1]; - - double vv[3]; - double *view_vector = vv; - double dot_1 = 0, dot_2 = 0; - double result; - bool material_back_face = ((tri1->flags | tri2->flags) & LRT_TRIANGLE_MAT_BACK_FACE_CULLING); - - if (rb->use_contour || rb->use_back_face_culling || material_back_face) { - -if (rb->cam_is_persp) { - sub_v3_v3v3_db(view_vector, rb->camera_pos, l->gloc); -} -else { - view_vector = rb->view_vector; -} - -dot_1 = dot_v3v3_db(view_vector, tri1->gn); -dot_2 = dot_v3v3_db(view_vector, tri2->gn); - -if (rb->use_contour && (result = dot_1 * dot_2) <= 0 && (fabs(dot_1) + fabs(dot_2))) { - edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; -} - -/* Because the ray points towards the camera, so backface is when dot value being negative.*/ -if (rb->use_back_face_culling) { - if (dot_1 < 0) { -tri1->flags |= LRT_CULL_DISCARD; - } - if (dot_2 < 0) { -tri2->flags |= LRT_CULL_DISCARD; - } -} -if (material_back_face) { - if (tri1->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_1 < 0) { -tri1->flags |= LRT_CULL_DISCARD; - } - if (tri2->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_2 < 0) { -tri2->flags |= LRT_CULL_DISCARD; - } -} - } - - /* For when face mark filtering decided that we discard the face but keep_contour option is on. - * so we still have correct full contour around the object. */ - if (only_contour) { -return edge_flag_result;
[Bf-blender-cvs] [33c581882b7] temp-lineart-contained: LineArt: Fix potentially NULL pending edge array.
Commit: 33c581882b7be4ab2b4aa9a647f1391639c9bb4c Author: YimingWu Date: Wed Apr 20 11:08:29 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB33c581882b7be4ab2b4aa9a647f1391639c9bb4c LineArt: Fix potentially NULL pending edge array. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 3e19a0cad97..5d1c8111b88 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3831,7 +3831,9 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb) lineart_end_bounding_area_recursive(>initial_bounding_areas[i]); } - MEM_freeN(rb->pending_edges.array); + if (rb->pending_edges.array) { +MEM_freeN(rb->pending_edges.array); + } lineart_mem_destroy(>render_data_pool); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7ef1f7648f4] temp-lineart-contained: LineArt: Index calculation based adjacent lookup WIP
Commit: 7ef1f7648f423cc2991c7599a7b3743971fdd184 Author: YimingWu Date: Wed Apr 20 10:53:21 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB7ef1f7648f423cc2991c7599a7b3743971fdd184 LineArt: Index calculation based adjacent lookup WIP === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 2a3f7653bdb..af82edfd0aa 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1450,6 +1450,28 @@ static void lineart_vert_transform( mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); } +static void lineart_vert_transform_me( +MVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4]) +{ + double co[4]; + LineartVert *vt = [index]; + copy_v3db_v3fl(co, v->co); + mul_v3_m4v3_db(vt->gloc, mv_mat, co); + mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co); +} + +typedef struct LineartAdjacentItem { + unsigned int v1; + unsigned int v2; + unsigned int e; +} LineartAdjacentItem; + +typedef struct LineartEdgeNeighbor { + int e; + short flags; + int v1, v2; +} LineartEdgeNeighbor; + typedef struct VertData { MVert *mvert; LineartVert *v_arr; @@ -1678,6 +1700,163 @@ static uint16_t lineart_identify_medge_feature_edges( return edge_flag_result; } +__attribute__((optimize("O0"))) static uint16_t lineart_identify_feature_line_me( +LineartRenderBuffer *rb, +int eindex, +LineartTriangle *rt_array, +LineartVert *rv_array, +float crease_threshold, +bool use_auto_smooth, +bool use_freestyle_edge, +bool use_freestyle_face, +Mesh *me, +LineartEdgeNeighbor *en, +float (*normals)[3]) +{ + + MPoly *ll = NULL, *lr = NULL; + + int t1i = -1, t1e = -1, t2i = -1; + if (en[eindex].e >= 0) { +t1i = en[eindex].e / 3; +t1e = en[eindex].e; + } + if (t1e >= 0 && en[t1e].e >= 0) { +t2i = en[t1e].e / 3; + } + + if (t1i >= 0) { +ll = >mpoly[me->runtime.looptris.array[t1i].poly]; + } + if (t2i >= 0) { +lr = >mpoly[me->runtime.looptris.array[t2i].poly]; + } + + if (t1i < 0 && t2i < 0) { +if (!rb->use_loose_as_contour) { + if (use_freestyle_face && rb->filter_face_mark) { +if (rb->filter_face_mark_invert) { + return LRT_EDGE_FLAG_LOOSE; +} +return 0; + } + return LRT_EDGE_FLAG_LOOSE; +} + } + + FreestyleEdge *fel, *fer; + bool face_mark_filtered = false; + bool only_contour = false; + + uint16_t edge_flag_result = 0; + + /* Mesh boundary */ + if (!ll || !lr) { +return (edge_flag_result | LRT_EDGE_FLAG_CONTOUR); + } + + LineartTriangle *tri1, *tri2; + LineartVert *l; + + /* The mesh should already be triangulated now, so we can assume each face is a triangle. */ + tri1 = lineart_triangle_from_index(rb, rt_array, t1i); + tri2 = lineart_triangle_from_index(rb, rt_array, t2i); + + l = _array[en[eindex].v1]; + + double vv[3]; + double *view_vector = vv; + double dot_1 = 0, dot_2 = 0; + double result; + bool material_back_face = ((tri1->flags | tri2->flags) & LRT_TRIANGLE_MAT_BACK_FACE_CULLING); + + if (rb->use_contour || rb->use_back_face_culling || material_back_face) { + +if (rb->cam_is_persp) { + sub_v3_v3v3_db(view_vector, rb->camera_pos, l->gloc); +} +else { + view_vector = rb->view_vector; +} + +dot_1 = dot_v3v3_db(view_vector, tri1->gn); +dot_2 = dot_v3v3_db(view_vector, tri2->gn); + +if (rb->use_contour && (result = dot_1 * dot_2) <= 0 && (fabs(dot_1) + fabs(dot_2))) { + edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; +} + +/* Because the ray points towards the camera, so backface is when dot value being negative.*/ +if (rb->use_back_face_culling) { + if (dot_1 < 0) { +tri1->flags |= LRT_CULL_DISCARD; + } + if (dot_2 < 0) { +tri2->flags |= LRT_CULL_DISCARD; + } +} +if (material_back_face) { + if (tri1->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_1 < 0) { +tri1->flags |= LRT_CULL_DISCARD; + } + if (tri2->flags & LRT_TRIANGLE_MAT_BACK_FACE_CULLING && dot_2 < 0) { +tri2->flags |= LRT_CULL_DISCARD; + } +} + } + + /* For when face mark filtering decided that we discard the face but keep_contour option is on. + * so we still have correct full contour around the object. */ + if (only_contour) { +return edge_flag_result; + } + + if (rb->use_light_contour) { +if (rb->light_is_sun) { +
[Bf-blender-cvs] [98a11a45992] temp-lineart-contained: Revert "LineArt: CAS-inspired tile tree (WIP)"
Commit: 98a11a45992162e52b6527b3b2a36a584a97cca0 Author: YimingWu Date: Tue Apr 19 15:48:25 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB98a11a45992162e52b6527b3b2a36a584a97cca0 Revert "LineArt: CAS-inspired tile tree (WIP)" This reverts commit b4e38ab9d04f02af6920ee8a614bb53ae49dd324. === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 85b9b64332e..6108629183c 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,7 +17,6 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc - ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 26675d101b2..a66412b854c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -226,7 +226,7 @@ typedef struct LineartRenderBuffer { float overscan; - struct LineartBoundingArea **initial_bounding_areas; + struct LineartBoundingArea *initial_bounding_areas; unsigned int bounding_area_initial_count; /* Array of thread_count length for spatial locks. */ @@ -465,7 +465,7 @@ typedef struct LineartBoundingArea { double cx, cy; /** 1,2,3,4 quadrant */ - struct LineartBoundingArea *child[4]; + struct LineartBoundingArea *child; SpinLock *lock; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 9feaf689af6..8b74fe905f7 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -459,25 +459,25 @@ static LineartBoundingArea *lineart_bounding_area_get_eci_recursive(LineartRende LineartBoundingArea *root, LineartEdgeChainItem *eci) { - if (root->child[0] == NULL) { + if (root->child == NULL) { return root; } - LineartBoundingArea **ch = root->child; + LineartBoundingArea *ch = root->child; #define IN_BOUND(ba, eci) \ - ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] + ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] if (IN_BOUND(ch[0], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[0], eci); +return lineart_bounding_area_get_eci_recursive(rb, [0], eci); } if (IN_BOUND(ch[1], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[1], eci); +return lineart_bounding_area_get_eci_recursive(rb, [1], eci); } if (IN_BOUND(ch[2], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[2], eci); +return lineart_bounding_area_get_eci_recursive(rb, [2], eci); } if (IN_BOUND(ch[3], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, ch[3], eci); +return lineart_bounding_area_get_eci_recursive(rb, [3], eci); } #undef IN_BOUND return NULL; @@ -507,7 +507,7 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, LineartEdgeChain *ec, LineartEdgeChainItem *eci) { - if (root->child[0] == NULL) { + if (root->child == NULL) { LineartChainRegisterEntry *cre = lineart_list_append_pointer_pool_sized( >linked_chains, rb->chain_data_pool, ec, sizeof(LineartChainRegisterEntry)); @@ -518,22 +518,22 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, } } else { -LineartBoundingArea **ch = root->child; +LineartBoundingArea *ch = root->child; #define IN_BOUND(ba, eci) \ - ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] + ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] if (IN_BOUND(ch[0], eci))
[Bf-blender-cvs] [b4e38ab9d04] temp-lineart-contained: LineArt: CAS-inspired tile tree (WIP)
Commit: b4e38ab9d04f02af6920ee8a614bb53ae49dd324 Author: YimingWu Date: Fri Apr 15 22:10:11 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBb4e38ab9d04f02af6920ee8a614bb53ae49dd324 LineArt: CAS-inspired tile tree (WIP) === M source/blender/gpencil_modifiers/CMakeLists.txt M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index 6108629183c..85b9b64332e 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -17,6 +17,7 @@ set(INC ../windowmanager ../../../intern/eigen ../../../intern/guardedalloc + ../../../intern/atomic # dna_type_offsets.h in BLO_read_write.h ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index a66412b854c..26675d101b2 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -226,7 +226,7 @@ typedef struct LineartRenderBuffer { float overscan; - struct LineartBoundingArea *initial_bounding_areas; + struct LineartBoundingArea **initial_bounding_areas; unsigned int bounding_area_initial_count; /* Array of thread_count length for spatial locks. */ @@ -465,7 +465,7 @@ typedef struct LineartBoundingArea { double cx, cy; /** 1,2,3,4 quadrant */ - struct LineartBoundingArea *child; + struct LineartBoundingArea *child[4]; SpinLock *lock; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 8b74fe905f7..9feaf689af6 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -459,25 +459,25 @@ static LineartBoundingArea *lineart_bounding_area_get_eci_recursive(LineartRende LineartBoundingArea *root, LineartEdgeChainItem *eci) { - if (root->child == NULL) { + if (root->child[0] == NULL) { return root; } - LineartBoundingArea *ch = root->child; + LineartBoundingArea **ch = root->child; #define IN_BOUND(ba, eci) \ - ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] + ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] if (IN_BOUND(ch[0], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [0], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[0], eci); } if (IN_BOUND(ch[1], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [1], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[1], eci); } if (IN_BOUND(ch[2], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [2], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[2], eci); } if (IN_BOUND(ch[3], eci)) { -return lineart_bounding_area_get_eci_recursive(rb, [3], eci); +return lineart_bounding_area_get_eci_recursive(rb, ch[3], eci); } #undef IN_BOUND return NULL; @@ -507,7 +507,7 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, LineartEdgeChain *ec, LineartEdgeChainItem *eci) { - if (root->child == NULL) { + if (root->child[0] == NULL) { LineartChainRegisterEntry *cre = lineart_list_append_pointer_pool_sized( >linked_chains, rb->chain_data_pool, ec, sizeof(LineartChainRegisterEntry)); @@ -518,22 +518,22 @@ static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb, } } else { -LineartBoundingArea *ch = root->child; +LineartBoundingArea **ch = root->child; #define IN_BOUND(ba, eci) \ - ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1] + ba->l <= eci->pos[0] && ba->r >= eci->pos[0] && ba->b <= eci->pos[1] && ba->u >= eci->pos[1] if (IN_BOUND(ch[0], eci)) { - lineart_bounding_area_link_point_recursive(rb, [0], ec, eci); +
[Bf-blender-cvs] [c83a9d13909] temp-lineart-contained: LineArt: Remove e->v1(2)_obindex.
Commit: c83a9d13909cf15ea13526739056d413ed003a5f Author: YimingWu Date: Fri Apr 8 13:33:59 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBc83a9d13909cf15ea13526739056d413ed003a5f LineArt: Remove e->v1(2)_obindex. This vairable is no longer needed, was left as a hack for some very rare situations in clipping and now those are replaced with v->index (object) instead which has the same effect. This part of the memory can then be used for other flags reserved for shadow information. === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c 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 fc2b9fff709..a66412b854c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -130,11 +130,7 @@ typedef struct LineartEdge { /** We only need link node kind of list here. */ struct LineartEdge *next; struct LineartVert *v1, *v2; - /** - * Local vertex index for two ends, not pouting in #RenderVert because all verts are loaded, so - * as long as fewer than half of the mesh edges are becoming a feature line, we save more memory. - */ - int v1_obindex, v2_obindex; + struct LineartTriangle *t1, *t2; ListBase segments; char min_occ; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 1864af5c3ad..8b74fe905f7 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -219,7 +219,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, -e->v1_obindex); +e->v1->index); while (ba && (new_e = lineart_line_get_connected( ba, new_vt, _vt, e->flags, ec->intersection_mask))) { new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; @@ -256,7 +256,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, es->occlusion, es->material_mask_bits, - new_e->v1_obindex); + new_e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -282,7 +282,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, - new_e->v2_obindex); + new_e->v2->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -295,7 +295,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, -new_e->v2_obindex); +new_e->v2->index); } ba = MOD_lineart_get_bounding_area(rb, new_vt->fbcoord[0], new_vt->fbcoord[1]); } @@ -336,7 +336,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, - e->v1_obindex); + e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -349,7 +349,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, last_occlusion, last_transparency, - e->v2_obindex); + e->v2->index); /* Step 3: grow right. */ ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]); @@ -402,7 +402,7 @@ void MOD_lineart_c
[Bf-blender-cvs] [d3e5d483875] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained
Commit: d3e5d48387532b6cfd55d87f688ee6230ee97462 Author: YimingWu Date: Thu Apr 14 21:18:24 2022 +0800 Branches: temp-lineart-contained https://developer.blender.org/rBd3e5d48387532b6cfd55d87f688ee6230ee97462 Merge remote-tracking branch 'origin/master' into temp-lineart-contained === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [40efc9fb580] lineart-shadow: LineArt: Light contour reprojection is working.
Commit: 40efc9fb5801629081724f28db4d5cadd5518433 Author: YimingWu Date: Tue Apr 12 16:27:20 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB40efc9fb5801629081724f28db4d5cadd5518433 LineArt: Light contour reprojection is working. === 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 3135cf142c3..a9d9c11e0f3 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -116,6 +116,7 @@ typedef struct LineartShadowSegmentContainer { double fbc1[4], fbc2[4]; double g1[3], g2[3]; struct LineartEdge *e_ref; + struct LineartEdge *e_ref_light_contour; struct LineartEdgeSegment *es_ref; /* Only for 3rd stage casting. */ ListBase shadow_segments; } LineartShadowSegmentContainer; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 244e600df8d..d96284d6b56 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -326,7 +326,7 @@ static void lineart_edge_cut(LineartRenderBuffer *rb, es->material_mask_bits |= material_mask_bits; /* Currently only register lit/shade, see LineartEdgeSegment::shadow_mask_bits for details. */ if (shadow_bits == LRT_SHADOW_MASK_ENCLOSED_SHAPE) { - if (es->shadow_mask_bits == LRT_SHADOW_MASK_LIT) { + if (es->shadow_mask_bits == LRT_SHADOW_MASK_LIT || e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { es->shadow_mask_bits = LRT_SHADOW_MASK_INHIBITED; } else if (es->shadow_mask_bits == LRT_SHADOW_MASK_SHADED) { @@ -2040,6 +2040,8 @@ static void lineart_load_tri_task(void *__restrict userdata, tri->intersection_mask = ob_info->override_intersection_mask; + tri->target_reference = (ob_info->obindex | (i & LRT_OBINDEX_LOWER)); + double gn[3]; float no[3]; normal_tri_v3(no, me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co); @@ -3208,7 +3210,8 @@ static bool lineart_edge_from_triangle(const LineartTriangle *tri, bool allow_overlapping_edges) { /* Normally we just determine from the pointer address. */ - if (e->t1 == tri || e->t2 == tri) { + if (e->t1 && e->t1->target_reference == tri->target_reference || + (e->t2 && e->t2->target_reference == tri->target_reference)) { return true; } /* If allows overlapping, then we compare the vertex coordinates one by one to determine if one @@ -5404,9 +5407,40 @@ static void lineart_shadow_create_container_array(LineartRenderBuffer *rb, LRT_ITER_ALL_LINES_BEGIN { /* Only contour and loose edges can actually cast shadows. */ -if (!(e->flags & (LRT_EDGE_FLAG_CONTOUR | LRT_EDGE_FLAG_LOOSE))) { +if (!(e->flags & + (LRT_EDGE_FLAG_CONTOUR | LRT_EDGE_FLAG_LOOSE | LRT_EDGE_FLAG_LIGHT_CONTOUR))) { continue; } +if (e->flags == LRT_EDGE_FLAG_LIGHT_CONTOUR) { + /* Only reproject light contours that also doubles as a view contour. */ + LineartEdge *orig_e = (LineartEdge *)e->t1; + if (!orig_e->t2) { +e->flags |= LRT_EDGE_FLAG_CONTOUR; + } + else { +double vv[3]; +double *view_vector = vv; +double dot_1 = 0, dot_2 = 0; +double result; + +if (rb->cam_is_persp) { + sub_v3_v3v3_db(view_vector, orig_e->v1->gloc, rb->camera_pos); +} +else { + view_vector = rb->view_vector; +} + +dot_1 = dot_v3v3_db(view_vector, orig_e->t1->gn); +dot_2 = dot_v3v3_db(view_vector, orig_e->t2->gn); + +if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { + e->flags |= LRT_EDGE_FLAG_CONTOUR; +} + } + if (!(e->flags & LRT_EDGE_FLAG_CONTOUR)) { +continue; + } +} LISTBASE_FOREACH (LineartEdgeSegment *, es, >segments) { DISCARD_NONSENSE_SEGMENTS segment_count++; @@ -5457,7 +5491,16 @@ static void lineart_shadow_create_container_array(LineartRenderBuffer *rb, BLI_addtail([i].shadow_segments, [i * 2]); BLI_addtail([i].shadow_segments, [i * 2 + 1]); - ssc[i].e_ref = e; + if (e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { +ssc[i].e_ref = e->t1; +ssc[i].e_ref_light_contour = e; +/* Restore original edge flag. */ +e->flags &= (~LRT_E
[Bf-blender-cvs] [a7ae8379f24] lineart-shadow: LineArt: Enclosed light/shadow shape support
Commit: a7ae8379f245eecd23cfba22e493ec6d7115ac20 Author: YimingWu Date: Mon Apr 11 23:09:45 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBa7ae8379f245eecd23cfba22e493ec6d7115ac20 LineArt: Enclosed light/shadow shape support === M source/blender/blenkernel/intern/gpencil_modifier.c M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index dc95816be75..91ef830edcc 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -222,6 +222,7 @@ GpencilLineartLimitInfo BKE_gpencil_get_lineart_modifier_limits(const Object *ob (lmd->use_multiple_levels ? lmd->level_end : lmd->level_start)); info.edge_types |= lmd->edge_types; info.shadow_selection = MAX2(lmd->shadow_selection, info.shadow_selection); +is_first = false; } } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 9ff7d0defb9..caa247c0d94 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -366,7 +366,7 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(sub, ptr, "use_light_contour", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "use_shadow", 0, IFACE_("Cast Shadow"), ICON_NONE); - uiItemR(sub, ptr, "shadow_region_filtering", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "shadow_region_filtering", 0, IFACE_("Regions"), ICON_NONE); uiItemR(layout, ptr, "use_overlap_edge_type_support", 0, IFACE_("Allow Overlap"), ICON_NONE); } @@ -400,6 +400,8 @@ static void options_light_reference_draw(const bContext *UNUSED(C), Panel *panel uiLayout *col = uiLayoutColumn(remaining, true); uiItemR(col, ptr, "shadow_camera_near", 0, "Near", ICON_NONE); uiItemR(col, ptr, "shadow_camera_far", 0, "Far", ICON_NONE); + + uiItemR(layout, ptr, "shadow_enclosed_shapes", 0, IFACE_("Eclosed Shapes"), ICON_NONE); } static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 22fa1517202..3135cf142c3 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -116,6 +116,7 @@ typedef struct LineartShadowSegmentContainer { double fbc1[4], fbc2[4]; double g1[3], g2[3]; struct LineartEdge *e_ref; + struct LineartEdgeSegment *es_ref; /* Only for 3rd stage casting. */ ListBase shadow_segments; } LineartShadowSegmentContainer; @@ -169,7 +170,10 @@ typedef enum eLineArtVertFlags { typedef struct LineartEdge { struct LineartVert *v1, *v2; + /** These two variables are also used to specify original edge and segment during 3rd stage + * reprojection, So we can easily find out the line which results come from. */ struct LineartTriangle *t1, *t2; + ListBase segments; char min_occ; @@ -369,7 +373,8 @@ typedef struct LineartRenderBuffer { bool use_shadow; bool use_contour_secondary; /* From viewing camera, during shadow calculation. */ - char shadow_selection; + int shadow_selection; /* Needs to be numeric because it's not just on/off. */ + bool shadow_enclose_shapes; bool fuzzy_intersections; bool fuzzy_everything; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c28ea6c769f..244e600df8d 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -135,6 +135,8 @@ static void lineart_add_edge_to_list(LineartPendingEdges *pe, LineartEdge *e); static LineartCache *lineart_init_cache(void); +static void lineart_clear_linked_edges(LineartRenderBuffer *rb); + static void lineart_discard_segment(LineartRenderBuffer *rb, LineartEdgeSegment *es) { BLI_spin_lock(>lock_cuts); @@ -166,6 +168,12 @@ static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb)
[Bf-blender-cvs] [75e17be7e76] lineart-shadow: LineArt: UI and correct logic for shadow region chaining
Commit: 75e17be7e7603458f7a5d09da42dcac34b629db1 Author: YimingWu Date: Mon Apr 11 15:08:21 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB75e17be7e7603458f7a5d09da42dcac34b629db1 LineArt: UI and correct logic for shadow region chaining === M source/blender/blenkernel/BKE_gpencil_modifier.h M source/blender/blenkernel/intern/gpencil_modifier.c M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c M source/blender/makesdna/DNA_gpencil_modifier_types.h M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c === diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h index 96c405e46ec..ff8b2a92f75 100644 --- a/source/blender/blenkernel/BKE_gpencil_modifier.h +++ b/source/blender/blenkernel/BKE_gpencil_modifier.h @@ -383,6 +383,7 @@ typedef struct GpencilLineartLimitInfo { char min_level; char max_level; short edge_types; + char shadow_selection; } GpencilLineartLimitInfo; GpencilLineartLimitInfo BKE_gpencil_get_lineart_modifier_limits(const struct Object *ob); diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index faafd1e1040..dc95816be75 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -221,6 +221,7 @@ GpencilLineartLimitInfo BKE_gpencil_get_lineart_modifier_limits(const Object *ob info.max_level = MAX2(info.max_level, (lmd->use_multiple_levels ? lmd->level_end : lmd->level_start)); info.edge_types |= lmd->edge_types; +info.shadow_selection = MAX2(lmd->shadow_selection, info.shadow_selection); } } } @@ -237,11 +238,13 @@ void BKE_gpencil_set_lineart_modifier_limits(GpencilModifierData *md, lmd->level_start_override = info->min_level; lmd->level_end_override = info->max_level; lmd->edge_types_override = info->edge_types; +lmd->shadow_selection_override = info->shadow_selection; } else { lmd->level_start_override = lmd->level_start; lmd->level_end_override = lmd->level_end; lmd->edge_types_override = lmd->edge_types; +lmd->shadow_selection_override = lmd->shadow_selection; } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 6b9c3c3c543..9ff7d0defb9 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -91,6 +91,7 @@ static void generate_strokes_actual( lmd->intersection_mask, lmd->thickness, lmd->opacity, + lmd->shadow_selection, lmd->source_vertex_group, lmd->vgname, lmd->flags); @@ -196,6 +197,7 @@ static void bakeModifier(Main *UNUSED(bmain), * modifiers in the stack. */ lmd->edge_types_override = lmd->edge_types; lmd->level_end_override = lmd->level_end; +lmd->shadow_selection_override = lmd->shadow_selection; MOD_lineart_compute_feature_lines( depsgraph, lmd, >runtime.lineart_cache, (!(ob->dtx & OB_DRAW_IN_FRONT))); @@ -363,7 +365,8 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetActive(sub, RNA_pointer_get(ptr, "light_contour_object").data != NULL); uiItemR(sub, ptr, "use_light_contour", 0, NULL, ICON_NONE); - uiItemR(sub, ptr, "use_shadow", 0, IFACE_("Casted Shadow"), ICON_NONE); + uiItemR(sub, ptr, "use_shadow", 0, IFACE_("Cast Shadow"), ICON_NONE); + uiItemR(sub, ptr, "shadow_region_filtering", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_overlap_edge_type_support", 0, IFACE_("Allow Overlap"), ICON_NONE); } diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index b9e05e3639c..22fa1517202 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -213,6 +213,7 @@ typedef struct LineartEdgeChain { int loop_id; unsigned char material_mask_bits; unsigned char intersection_mask; + unsigned char shadow_mask_bits; struct Objec
[Bf-blender-cvs] [4c291b1191d] lineart-shadow: LineArt: Lit/shade filtering logic corrected.
Commit: 4c291b1191d09d564f6a57f8f6f8bd0210ceafcb Author: YimingWu Date: Fri Apr 8 22:08:31 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB4c291b1191d09d564f6a57f8f6f8bd0210ceafcb LineArt: Lit/shade filtering logic corrected. Intersection lines won't work at the moment. === 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 463846fb9fc..b9e05e3639c 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -87,6 +87,9 @@ typedef struct LineartElementLinkNode { void *object_ref; eLineArtElementNodeFlag flags; + /* For edge element link nodes, used for shadow edge matching. */ + int obindex; + /** Per object value, always set, if not enabled by #ObjectLineArt, then it's set to global. */ float crease_threshold; } LineartElementLinkNode; @@ -100,6 +103,11 @@ typedef struct LineartEdgeSegment { /* Used to filter line art occlusion edges */ unsigned char material_mask_bits; + + /* Only used to mark "lit/shade" for now, But reserverd bits for material info. + * TODO(Yiming): Transfer material masks from shadow results + * onto here so then we can even filter transparent shadows. */ + unsigned char shadow_mask_bits; } LineartEdgeSegment; typedef struct LineartShadowSegmentContainer { @@ -305,6 +313,11 @@ typedef struct LineartRenderBuffer { * calculation is finished. */ LineartStaticMemPool *shadow_data_pool; + /* Storing shadow edge eln, array, and cuts for shadow information, so it's avaliable when line + * art runs the second time for occlusion. Either a reference to LineartCache::shadow_data_pool + * (shadow stage) or a reference to LineartRenderBuffer::render_data_pool (final stage). */ + LineartStaticMemPool *edge_data_pool; + /* Render status */ double view_vector[3]; double view_vector_secondary[3]; /* For shadow. */ @@ -417,8 +430,10 @@ typedef struct LineartCache { /** A copy of rb->Chains after calculation is done, then we can destroy rb. */ ListBase chains; - /** Shadow segments to be included into occlusion calculation in the second run of line art. */ - ListBase shadow_edges; + + /** Shadow-computed feature lines from original meshes to be matched with the second load of + * meshes thus providing lit/shade info in the second run of line art. */ + ListBase shadow_elns; /** Cache only contains edge types specified in this variable. */ uint16_t rb_edge_types; @@ -472,8 +487,8 @@ typedef struct LineartRenderTaskInfo { #define LRT_OBINDEX_SHIFT 20 #define LRT_OBINDEX_LOWER 0x0f /* Lower 20 bits. */ #define LRT_EDGE_IDENTIFIER(obi, e) \ - obi->obindex << LRT_OBINDEX_SHIFT) | (e->v1->index & LRT_OBINDEX_LOWER)) << 32) | \ - ((obi->obindex << LRT_OBINDEX_SHIFT) | (e->v2->index & LRT_OBINDEX_LOWER))) + (((uint64_t)((obi->obindex << 0) | (e->v1->index & LRT_OBINDEX_LOWER)) << 32) | \ + ((obi->obindex << 0) | (e->v2->index & LRT_OBINDEX_LOWER))) typedef struct LineartObjectInfo { struct LineartObjectInfo *next; @@ -515,6 +530,7 @@ typedef struct LineartObjectLoadTaskInfo { LineartObjectInfo *pending; /* Used to spread the load across several threads. This can not overflow. */ uint64_t total_faces; + ListBase *shadow_elns; } LineartObjectLoadTaskInfo; /** diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index cf11c1dea1a..821e137985e 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -162,7 +162,7 @@ static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb) BLI_spin_unlock(>lock_cuts); /* Otherwise allocate some new memory. */ - return (LineartEdgeSegment *)lineart_mem_acquire_thread(>render_data_pool, + return (LineartEdgeSegment *)lineart_mem_acquire_thread(rb->edge_data_pool, sizeof(LineartEdgeSegment)); } @@ -174,7 +174,8 @@ static void lineart_edge_cut(LineartRenderBuffer *rb, double start, double end, uchar material_mask_bits, - uchar mat_occlusion) + uchar mat_occlusion, + uchar shadow_bits) { LineartEdgeSegment *es, *ies, *next_es, *prev_es; L
[Bf-blender-cvs] [08f5361d746] lineart-shadow: LineArt: WIP shadow matching.
Commit: 08f5361d746084fafbc127ce8d31b6aa65791a5a Author: YimingWu Date: Fri Apr 8 11:16:30 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB08f5361d746084fafbc127ce8d31b6aa65791a5a LineArt: WIP shadow matching. === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h M source/blender/gpencil_modifiers/intern/lineart/lineart_util.c M source/blender/makesdna/DNA_lineart_types.h === diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 7549362baf2..0dce7636843 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -159,8 +159,6 @@ typedef enum eLineArtVertFlags { } eLineArtVertFlags; typedef struct LineartEdge { - /** We only need link node kind of list here. */ - struct LineartEdge *next; struct LineartVert *v1, *v2; /** * Local vertex index for two ends, not pouting in #RenderVert because all verts are loaded, so @@ -175,6 +173,13 @@ typedef struct LineartEdge { uint16_t flags; uint8_t intersection_mask; + /** Matches the shadow result, used to determine whether a line is in the shadow or not. + * Usages: + * - Intersection lines: ((e->t1->target_reference << 32) | e->t2->target_reference); + * - Other lines: LRT_EDGE_IDENTIFIER(obi, e); + * - After shadow calculation: (search the shadow result and set reference to that); + */ + struct LineartEdge *from_shadow; int target_reference; /** @@ -306,6 +311,7 @@ typedef struct LineartRenderBuffer { /* Render status */ double view_vector[3]; + double view_vector_secondary[3]; /* For shadow. */ int triangle_size; @@ -350,6 +356,10 @@ typedef struct LineartRenderBuffer { bool use_loose; bool use_light_contour; bool use_shadow; + bool use_contour_secondary; /* From viewing camera, during shadow calculation. */ + + bool needs_shadow_separation; + bool fuzzy_intersections; bool fuzzy_everything; bool allow_boundaries; @@ -374,8 +384,12 @@ typedef struct LineartRenderBuffer { /* Keep an copy of these data so when line art is running it's self-contained. */ bool cam_is_persp; + bool cam_is_persp_secondary; /* "Secondary" ones are from viewing camera (as opposed to shadow + camera), during shadow calculation. */ float cam_obmat[4][4]; + float cam_obmat_secondary[4][4]; double camera_pos[3]; + double camera_pos_secondary[3]; double active_camera_pos[3]; /* Stroke offset calculation may use active or selected camera. */ double near_clip, far_clip; float shift_x, shift_y; @@ -461,6 +475,9 @@ typedef struct LineartRenderTaskInfo { #define LRT_OBINDEX_SHIFT 20 #define LRT_OBINDEX_LOWER 0x0f /* Lower 20 bits. */ +#define LRT_EDGE_IDENTIFIER(obi, e) \ + obi->obindex << LRT_OBINDEX_SHIFT) | (e->v1->index & LRT_OBINDEX_LOWER)) << 32) | \ + ((obi->obindex << LRT_OBINDEX_SHIFT) | (e->v2->index & LRT_OBINDEX_LOWER))) typedef struct LineartObjectInfo { struct LineartObjectInfo *next; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 2f24326bbf4..a382771c01b 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1618,6 +1618,24 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; } +if (rb->use_contour_secondary) { + if (rb->cam_is_persp_secondary) { +sub_v3_v3v3_db(view_vector, vert->gloc, rb->camera_pos_secondary); + } + else { +view_vector = rb->view_vector_secondary; + } + + dot_1 = dot_v3v3_db(view_vector, tri1->gn); + dot_2 = dot_v3v3_db(view_vector, tri2->gn); + + if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { +/* Note: we only allow one contour type for now, either it's from light camera or it's from + * viewing camera, hence directly assign. */ +edge_flag_result = LRT_EDGE_FLAG_CONTOUR_SECONDARY; + } +} + if (!only_contour) { if (rb->use_crease) { @@ -2436,6 +2454,7 @@ static void lineart_geometry_object_load_no_bmesh(LineartObjectInfo *ob_info, } la_edge->flags = use_type; la_edge->object_ref = orig_ob; + la_edge->from_shadow = (LineartEdge *)LRT_EDGE_IDENTIFIER(ob_info, la_edge)
[Bf-blender-cvs] [8fbfd1f7d3a] lineart-shadow: LineArt: Remove e->v1(2)_obindex.
Commit: 8fbfd1f7d3ad0f8ca1ce01a23a5a11e6c59155eb Author: YimingWu Date: Fri Apr 8 13:33:59 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB8fbfd1f7d3ad0f8ca1ce01a23a5a11e6c59155eb LineArt: Remove e->v1(2)_obindex. This vairable is no longer needed, was left as a hack for some very rare situations in clipping and now those are replaced with v->index (object) instead which has the same effect. This part of the memory can then be used for other flags reserved for shadow information. === M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c 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 0dce7636843..463846fb9fc 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -160,11 +160,7 @@ typedef enum eLineArtVertFlags { typedef struct LineartEdge { struct LineartVert *v1, *v2; - /** - * Local vertex index for two ends, not pouting in #RenderVert because all verts are loaded, so - * as long as fewer than half of the mesh edges are becoming a feature line, we save more memory. - */ - int v1_obindex, v2_obindex; + struct LineartTriangle *t1, *t2; ListBase segments; char min_occ; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c index 1c94cd12dea..1b56fe1fb33 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c @@ -219,7 +219,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, -e->v1_obindex); +e->v1->index); while (ba && (new_e = lineart_line_get_connected( ba, new_vt, _vt, e->flags, ec->intersection_mask))) { new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; @@ -256,7 +256,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, es->occlusion, es->material_mask_bits, - new_e->v1_obindex); + new_e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -282,7 +282,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, - new_e->v2_obindex); + new_e->v2->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -295,7 +295,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) new_e->flags, last_occlusion, last_transparency, -new_e->v2_obindex); +new_e->v2->index); } ba = MOD_lineart_get_bounding_area(rb, new_vt->fbcoord[0], new_vt->fbcoord[1]); } @@ -336,7 +336,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, es->occlusion, es->material_mask_bits, - e->v1_obindex); + e->v1->index); last_occlusion = es->occlusion; last_transparency = es->material_mask_bits; } @@ -349,7 +349,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb) e->flags, last_occlusion, last_transparency, - e->v2_obindex); + e->v2->index); /* Step 3: grow right. */ ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]); @@ -402,7 +402,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
[Bf-blender-cvs] [80b5f27d232] lineart-shadow: LineArt: Adapt new object loading changes.
Commit: 80b5f27d232e18890156ad79bf8eebab1475b6fc Author: YimingWu Date: Thu Apr 7 20:24:48 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB80b5f27d232e18890156ad79bf8eebab1475b6fc LineArt: Adapt new object loading changes. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 256bd2ea776..93ba4e238f4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -482,10 +482,6 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR eip = rti->pending_edges.array[i]; lineart_occlusion_single_line(rb, eip, rti->thread_id); } - -for (eip = rti->shadow.first; eip && eip != rti->shadow.last; eip = eip->next) { - lineart_occlusion_single_line(rb, eip, rti->thread_id); -} } } @@ -3894,6 +3890,8 @@ static void lineart_destroy_render_data_keep_init(LineartRenderBuffer *rb) BLI_listbase_clear(>line_buffer_pointers); BLI_listbase_clear(>triangle_buffer_pointers); + MEM_freeN(rb->pending_edges.array); + lineart_mem_destroy(>render_data_pool); } @@ -5950,7 +5948,7 @@ static void lineart_transform_and_add_shadow(LineartRenderBuffer *rb, } LineartEdge *e = eeln->pointer; for (int i = 0; i < eeln->element_count; i++) { -lineart_add_edge_to_list(rb, [i]); +lineart_add_edge_to_list(>pending_edges, [i]); } BLI_addtail(>vertex_buffer_pointers, veln); BLI_addtail(>line_buffer_pointers, eeln); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [27c8f7eeb39] lineart-shadow: LineArt: Separate cast shadow and light contour in shadow edge loading.
Commit: 27c8f7eeb3936193c69a968d4beed2e5c58599aa Author: YimingWu Date: Thu Apr 7 21:00:06 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rB27c8f7eeb3936193c69a968d4beed2e5c58599aa LineArt: Separate cast shadow and light contour in shadow edge loading. === M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 93ba4e238f4..2f24326bbf4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1835,7 +1835,7 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb, dot_2 = dot_v3v3_db(view_vector, tri2->gn); if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) { - edge_flag_result |= LRT_EDGE_FLAG_LIGHT_CONTOUR; + // edge_flag_result |= LRT_EDGE_FLAG_LIGHT_CONTOUR; } } @@ -3250,7 +3250,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl), dot_r = dot_v3v3_db(Rv, tri->gn); dot_f = dot_v3v3_db(Cv, tri->gn); - if ((e->flags & LRT_EDGE_FLAG_PROJECTED_SHADOW) && + if (((e->flags & LRT_EDGE_FLAG_PROJECTED_SHADOW) || (e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR)) && (e->target_reference == tri->target_reference || !e->target_reference) && LRT_SHADOW_CLOSE_ENOUGH(dot_l, 0) && LRT_SHADOW_CLOSE_ENOUGH(dot_r, 0)) { /* Currently unable to precisely determine if the edge is really from this triangle. */ @@ -5771,7 +5771,7 @@ static bool lineart_shadow_cast_generate_edges(LineartRenderBuffer *rb, tot_orig_edges++; } - int edge_alloc = tot_orig_edges + tot_edges; + int edge_alloc = tot_edges + tot_orig_edges; if (G.debug_value == 4000) { printf("Line art shadow segments total: %d\n", tot_edges); @@ -5828,7 +5828,7 @@ static bool lineart_shadow_cast_generate_edges(LineartRenderBuffer *rb, //} e->v1 = v1; e->v2 = v2; -e->flags = LRT_EDGE_FLAG_PROJECTED_SHADOW; +e->flags = LRT_EDGE_FLAG_LIGHT_CONTOUR; i++; } return true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs