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:
authorMatt Ebb <matt@mke3.net>2010-01-07 04:27:10 +0300
committerMatt Ebb <matt@mke3.net>2010-01-07 04:27:10 +0300
commit23764238e5d0991206334ff6f0df75fc26edaa1e (patch)
treeed3a66163ca6cc2ddb38e17ee70813d265192fac
parentd3a718dc2f556fd8a0dbf6e89e5317d7e85a44f2 (diff)
Replaced lasso gesture filling code with scanfill, not 100% as nice, but simpler and more compatible.
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c86
1 files changed, 33 insertions, 53 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index c0717f233d3..a57421560a6 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -37,6 +37,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_editVert.h" /* lasso tessellation */
+#include "BLI_scanfill.h" /* lasso tessellation */
#include "BKE_context.h"
#include "BKE_utildefines.h"
@@ -209,69 +211,47 @@ static void wm_gesture_draw_circle(wmWindow *win, wmGesture *gt)
}
-#ifndef WIN32
-/* Disabled for now, causing problems on Windows.. */
-
-/* more than 64 intersections will just leak.. not much and not a likely scenario */
-typedef struct TessData { int num; short *intersections[64]; } TessData;
-
-static void combine_cb(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], void **dataOut, void *data)
-{
- short *vertex;
- TessData *td = (TessData *)data;
- vertex = (short *)malloc(2*sizeof(short));
- vertex[0] = (short)coords[0];
- vertex[1] = (short)coords[1];
- *dataOut = vertex;
-
- if (td->num < 64) {
- td->intersections[td->num++] = vertex;
- }
-}
-
-static void free_tess_data(GLUtesselator *tess, TessData *td)
-{
- int i;
- for (i=0; i<td->num; i++) {
- free(td->intersections[i]);
- }
- MEM_freeN(td);
- td = NULL;
- gluDeleteTess(tess);
-}
-
-#endif
-
-static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt)
+static void draw_filled_lasso(wmGesture *gt)
{
+ EditVert *v, *lastv=NULL, *firstv=NULL;
+ EditEdge *e;
+ EditFace *efa;
short *lasso= (short *)gt->customdata;
int i;
-
-#ifndef WIN32
- TessData *data=MEM_callocN(sizeof(TessData), "tesselation data");
- GLUtesselator *tess = gluNewTess();
- /* use GLU tesselator to draw a filled lasso shape */
- gluTessCallback(tess, GLU_TESS_BEGIN, glBegin);
- gluTessCallback(tess, GLU_TESS_VERTEX, glVertex2sv);
- gluTessCallback(tess, GLU_TESS_END, glEnd);
- gluTessCallback(tess, GLU_TESS_COMBINE_DATA, combine_cb);
-
+ for (i=0; i<gt->points; i++, lasso+=2) {
+ float co[3] = {(float)lasso[0], (float)lasso[1], 0.f};
+
+ v = BLI_addfillvert(co);
+ if (lastv)
+ e = BLI_addfilledge(lastv, v);
+ lastv = v;
+ if (firstv==NULL) firstv = v;
+ }
+
+ BLI_addfilledge(firstv, v);
+ BLI_edgefill(0, 0);
+
glEnable(GL_BLEND);
glColor4f(1.0, 1.0, 1.0, 0.05);
- gluTessBeginPolygon (tess, data);
- gluTessBeginContour (tess);
- for (i=0; i<gt->points; i++, lasso+=2) {
- GLdouble d_lasso[2] = {(GLdouble)lasso[0], (GLdouble)lasso[1]};
- gluTessVertex (tess, d_lasso, lasso);
+ glBegin(GL_TRIANGLES);
+ for (efa = fillfacebase.first; efa; efa=efa->next) {
+ glVertex2f(efa->v1->co[0], efa->v1->co[1]);
+ glVertex2f(efa->v2->co[0], efa->v2->co[1]);
+ glVertex2f(efa->v3->co[0], efa->v3->co[1]);
}
- gluTessEndContour (tess);
- gluTessEndPolygon (tess);
+ glEnd();
glDisable(GL_BLEND);
- free_tess_data(tess, data);
+ BLI_end_edgefill();
+}
+
+static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt)
+{
+ short *lasso= (short *)gt->customdata;
+ int i;
-#endif
+ draw_filled_lasso(gt);
glEnable(GL_LINE_STIPPLE);
glColor3ub(96, 96, 96);