[Bf-blender-cvs] [e7ff8deee80] temp-lineart-contained: LineArt: Protecting bounding area links.
YimingWu
noreply at git.blender.org
Mon Dec 27 07:55:01 CET 2021
Commit: e7ff8deee80203b13d6a5c6e6dcdc4b839fb6899
Author: YimingWu
Date: Mon Dec 27 14:33:39 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBe7ff8deee80203b13d6a5c6e6dcdc4b839fb6899
LineArt: Protecting bounding area links.
In case they overflowed the bounding area maximum link count,
Protect the link array so it doesn't crash.
===================================================================
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 9c7e202d475..695fb549694 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -466,10 +466,10 @@ typedef struct LineartBoundingArea {
ListBase up;
ListBase bp;
- int16_t triangle_count;
- int16_t max_triangle_count;
- int16_t line_count;
- int16_t max_line_count;
+ uint16_t triangle_count;
+ uint16_t max_triangle_count;
+ uint16_t line_count;
+ uint16_t max_line_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 728b1ad1e18..3ddf8222157 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -360,7 +360,12 @@ BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartEdge *e, Linea
static void lineart_bounding_area_triangle_add(LineartRenderBuffer *rb,
LineartBoundingArea *ba,
LineartTriangle *tri)
-{
+{ /* In case of too many triangles concentrating in one point, do not add anymore, these triangles
+ * will be either narrower than a single pixel, or will still be added into the list of other
+ * less dense areas. */
+ if (ba->triangle_count >= 65535) {
+ return;
+ }
if (ba->triangle_count >= ba->max_triangle_count) {
LineartTriangle **new_array = lineart_mem_acquire_thread(
&rb->render_data_pool, sizeof(LineartTriangle *) * ba->max_triangle_count * 2);
@@ -376,6 +381,12 @@ static void lineart_bounding_area_line_add(LineartRenderBuffer *rb,
LineartBoundingArea *ba,
LineartEdge *edge)
{
+ /* In case of too many lines concentrating in one point, do not add anymore, these lines will
+ * be either shorter than a single pixel, or will still be added into the list of other less
+ * dense areas. */
+ if (ba->line_count >= 65535) {
+ return;
+ }
if (ba->line_count >= ba->max_line_count) {
LineartEdge **new_array = lineart_mem_acquire(&rb->render_data_pool,
sizeof(LineartEdge *) * ba->max_line_count * 2);
More information about the Bf-blender-cvs
mailing list