Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-16 22:24:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-16 22:24:49 +0400
commit195d6c1b1a363bb30b6efaf9c274cc45edaa6f9a (patch)
treefd3918bd89fb7d60c385043e291611819af93eb0 /source/blender/blenlib
parent67f8e3a3a7af4146b9bb7ae40f1bdc8dabc2b48f (diff)
minor speedup for scanfill, dont calculate the normal if its already known - use for editmode ngon filling.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_scanfill.h2
-rw-r--r--source/blender/blenlib/intern/scanfill.c40
2 files changed, 28 insertions, 14 deletions
diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h
index 67ff9a88700..5a5e55cc90a 100644
--- a/source/blender/blenlib/BLI_scanfill.h
+++ b/source/blender/blenlib/BLI_scanfill.h
@@ -100,6 +100,8 @@ struct ScanFillEdge *BLI_addfilledge(ScanFillContext *sf_ctx, struct ScanFillVer
int BLI_begin_edgefill(ScanFillContext *sf_ctx);
int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup);
+int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup,
+ const float nor_proj[3]);
void BLI_end_edgefill(ScanFillContext *sf_ctx);
/* These callbacks are needed to make the lib finction properly */
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 1b60d58b154..4878ad628ef 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -774,6 +774,11 @@ int BLI_begin_edgefill(ScanFillContext *sf_ctx)
int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup)
{
+ return BLI_edgefill_ex(sf_ctx, do_quad_tri_speedup, NULL);
+}
+
+int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, const float nor_proj[3])
+{
/*
* - fill works with its own lists, so create that first (no faces!)
* - for vertices, put in ->tmp.v the old pointer
@@ -852,21 +857,28 @@ int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup)
return 0;
}
else {
- /* define projection: with 'best' normal */
- /* Newell's Method */
- /* Similar code used elsewhere, but this checks for double ups
- * which historically this function supports so better not change */
- float *v_prev;
- float n[3] = {0.0f};
-
- eve = sf_ctx->fillvertbase.last;
- v_prev = eve->co;
-
- for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
- if (LIKELY(!compare_v3v3(v_prev, eve->co, COMPLIMIT))) {
- add_newell_cross_v3_v3v3(n, v_prev, eve->co);
- }
+ float n[3];
+
+ if (nor_proj) {
+ copy_v3_v3(n, nor_proj);
+ }
+ else {
+ /* define projection: with 'best' normal */
+ /* Newell's Method */
+ /* Similar code used elsewhere, but this checks for double ups
+ * which historically this function supports so better not change */
+ float *v_prev;
+
+ zero_v3(n);
+ eve = sf_ctx->fillvertbase.last;
v_prev = eve->co;
+
+ for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
+ if (LIKELY(!compare_v3v3(v_prev, eve->co, COMPLIMIT))) {
+ add_newell_cross_v3_v3v3(n, v_prev, eve->co);
+ }
+ v_prev = eve->co;
+ }
}
if (UNLIKELY(normalize_v3(n) == 0.0f)) {