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
parent67f8e3a3a7af4146b9bb7ae40f1bdc8dabc2b48f (diff)
minor speedup for scanfill, dont calculate the normal if its already known - use for editmode ngon filling.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c2
-rw-r--r--source/blender/blenlib/BLI_scanfill.h2
-rw-r--r--source/blender/blenlib/intern/scanfill.c40
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c2
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c3
6 files changed, 35 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 07a43db8560..d9a011d481f 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -218,7 +218,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm)
/*complete the loop*/
BLI_addfilledge(&sf_ctx, firstv, v);
- totfilltri = BLI_edgefill(&sf_ctx, FALSE);
+ totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no);
BLI_array_growitems(looptris, totfilltri);
for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) {
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)) {
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 77e50b1ea3f..1b480ab0315 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -529,8 +529,8 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2],
GETMIN2(v1, v2, mv1, mv2);
GETMIN2(v3, v4, mv3, mv4);
- /* do an interval test on the x and y axe */
- /* first do x axi */
+ /* do an interval test on the x and y axes */
+ /* first do x axis */
if (ABS(v1[1] - v2[1]) < EPS &&
ABS(v3[1] - v4[1]) < EPS &&
ABS(v1[1] - v3[1]) < EPS)
@@ -538,7 +538,7 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2],
return (mv4[0] >= mv1[0] && mv3[0] <= mv2[0]);
}
- /* now do y axi */
+ /* now do y axis */
if (ABS(v1[0] - v2[0]) < EPS &&
ABS(v3[0] - v4[0]) < EPS &&
ABS(v1[0] - v3[0]) < EPS)
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 5b3c4f9cd97..6e1506d4c0f 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -288,7 +288,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BLI_addfilledge(&sf_ctx, firstv, v);
- BLI_edgefill(&sf_ctx, TRUE);
+ BLI_edgefill_ex(&sf_ctx, TRUE, efa->no);
for (sefa = sf_ctx.fillfacebase.first; sefa; sefa = sefa->next) {
ls[0] = sefa->v1->tmp.p;
ls[1] = sefa->v2->tmp.p;
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 0add9106872..bfa3645bf57 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -253,8 +253,9 @@ static void draw_filled_lasso(wmGesture *gt)
/* highly unlikely this will fail, but could crash if (gt->points == 0) */
if (firstv) {
+ float zvec[3] = {0.0f, 0.0f, 1.0f};
BLI_addfilledge(&sf_ctx, firstv, v);
- BLI_edgefill(&sf_ctx, FALSE);
+ BLI_edgefill_ex(&sf_ctx, FALSE, zvec);
glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05);