diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-04 22:22:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-04 22:27:01 +0400 |
commit | 6c17d2141bf596672f6916d8d5897bcd53d3537d (patch) | |
tree | 7768401057f87d19f810407966dee2ab35ea15d5 /source/blender/blenlib | |
parent | db749684023176d00d7b1bdfe7f56527b72549e3 (diff) |
Scanfill: optimize filling curves, text, masks - skip calculating holes
Support for tagging polygon numbers when adding scanfill data,
saves having to calculate connectivity afterwards (which can take approx half overall scanfill time for complex curves).
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_scanfill.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/scanfill.c | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index bb91b747223..d77640ea187 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -46,6 +46,10 @@ typedef struct ScanFillContext { ListBase filledgebase; ListBase fillfacebase; + /* increment this value before adding each curve to skip having to calculate + * 'poly_nr' for edges and verts (which can take approx half scanfill time) */ + unsigned short poly_nr; + /* private */ struct ScanFillVertLink *_scdata; struct MemArena *arena; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index bbd15e16328..2c095bc3533 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -117,7 +117,7 @@ ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]) /* just zero out the rest */ zero_v2(sf_v->xy); sf_v->keyindex = 0; - sf_v->poly_nr = 0; + sf_v->poly_nr = sf_ctx->poly_nr; sf_v->edge_tot = 0; sf_v->f = 0; @@ -135,7 +135,7 @@ ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, S sf_ed->v2 = v2; /* just zero out the rest */ - sf_ed->poly_nr = 0; + sf_ed->poly_nr = sf_ctx->poly_nr; sf_ed->f = 0; sf_ed->tmp.c = 0; @@ -784,7 +784,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const /* these values used to be set, * however they should always be zero'd so check instead */ BLI_assert(eve->f == 0); - BLI_assert(eve->poly_nr == 0); + BLI_assert(sf_ctx->poly_nr || eve->poly_nr == 0); BLI_assert(eve->edge_tot == 0); } #endif @@ -824,7 +824,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const /* first test vertices if they are in edges */ /* including resetting of flags */ for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) { - BLI_assert(eed->poly_nr == 0); + BLI_assert(sf_ctx->poly_nr || eed->poly_nr == 0); eed->v1->f = SF_VERT_AVAILABLE; eed->v2->f = SF_VERT_AVAILABLE; } @@ -872,7 +872,12 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const /* STEP 1: COUNT POLYS */ - if (flag & BLI_SCANFILL_CALC_HOLES) { + if (sf_ctx->poly_nr) { + poly = sf_ctx->poly_nr; + sf_ctx->poly_nr = 0; + } + + if (flag & BLI_SCANFILL_CALC_HOLES && (poly == 0)) { for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) { mul_v2_m3v3(eve->xy, mat_2d, eve->co); @@ -915,6 +920,12 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const } /* printf("amount of poly's: %d\n", poly); */ } + else if (poly) { + /* we pre-calculated poly_nr */ + for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) { + mul_v2_m3v3(eve->xy, mat_2d, eve->co); + } + } else { poly = 1; |