[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16246] branches/apricot/source: svn merge -r 16239:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/ blender
Campbell Barton
ideasman42 at gmail.com
Mon Aug 25 12:12:18 CEST 2008
Revision: 16246
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16246
Author: campbellbarton
Date: 2008-08-25 12:11:43 +0200 (Mon, 25 Aug 2008)
Log Message:
-----------
svn merge -r 16239:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
Modified Paths:
--------------
branches/apricot/source/blender/include/BIF_editview.h
branches/apricot/source/blender/include/transform.h
branches/apricot/source/blender/makesdna/DNA_gpencil_types.h
branches/apricot/source/blender/src/drawgpencil.c
branches/apricot/source/blender/src/editmesh_tools.c
branches/apricot/source/blender/src/editnode.c
branches/apricot/source/blender/src/editview.c
branches/apricot/source/blender/src/gpencil.c
branches/apricot/source/blender/src/transform_generics.c
branches/apricot/source/blender/src/transform_numinput.c
branches/apricot/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
Modified: branches/apricot/source/blender/include/BIF_editview.h
===================================================================
--- branches/apricot/source/blender/include/BIF_editview.h 2008-08-25 09:52:38 UTC (rev 16245)
+++ branches/apricot/source/blender/include/BIF_editview.h 2008-08-25 10:11:43 UTC (rev 16246)
@@ -40,6 +40,7 @@
void lasso_select_boundbox(struct rcti *rect, short mcords[][2], short moves);
int lasso_inside(short mcords[][2], short moves, short sx, short sy);
int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1);
+int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2);
void borderselect(void);
void circle_select(void);
void deselectall(void);
Modified: branches/apricot/source/blender/include/transform.h
===================================================================
--- branches/apricot/source/blender/include/transform.h 2008-08-25 09:52:38 UTC (rev 16245)
+++ branches/apricot/source/blender/include/transform.h 2008-08-25 10:11:43 UTC (rev 16246)
@@ -466,7 +466,6 @@
/*********************** Generics ********************************/
void initTrans(TransInfo *t);
-void initTransModeFlags(TransInfo *t, int mode);
void postTrans (TransInfo *t);
void drawLine(float *center, float *dir, char axis, short options);
@@ -498,6 +497,7 @@
/*********************** NumInput ********************************/
+void initNumInput(NumInput *n);
void outputNumInput(NumInput *n, char *str);
short hasNumInput(NumInput *n);
void applyNumInput(NumInput *n, float *vec);
Modified: branches/apricot/source/blender/makesdna/DNA_gpencil_types.h
===================================================================
--- branches/apricot/source/blender/makesdna/DNA_gpencil_types.h 2008-08-25 09:52:38 UTC (rev 16245)
+++ branches/apricot/source/blender/makesdna/DNA_gpencil_types.h 2008-08-25 10:11:43 UTC (rev 16246)
@@ -61,7 +61,7 @@
#define GP_STROKE_2DSPACE (1<<1)
/* stroke is in 2d-space (but with special 'image' scaling) */
#define GP_STROKE_2DIMAGE (1<<2)
- /* stroke is an "eraser" stroke */
+ /* only for use with stroke-buffer (while drawing eraser) */
#define GP_STROKE_ERASER (1<<15)
Modified: branches/apricot/source/blender/src/drawgpencil.c
===================================================================
--- branches/apricot/source/blender/src/drawgpencil.c 2008-08-25 09:52:38 UTC (rev 16245)
+++ branches/apricot/source/blender/src/drawgpencil.c 2008-08-25 10:11:43 UTC (rev 16246)
@@ -323,6 +323,9 @@
GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */
};
+/* thickness above which we should use special drawing */
+#define GP_DRAWTHICKNESS_SPECIAL 3
+
/* ----- Tool Buffer Drawing ------ */
/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
@@ -347,23 +350,13 @@
glEnd();
}
else if (sflag & GP_STROKE_ERASER) {
- /* draw stroke curve - just standard thickness */
- setlinestyle(4);
- glLineWidth(1.0f);
-
- glBegin(GL_LINE_STRIP);
- for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
- glVertex2f(pt->x, pt->y);
- }
- glEnd();
-
- setlinestyle(0);
+ /* don't draw stroke at all! */
}
else {
float oldpressure = 0.0f;
/* draw stroke curve */
- setlinestyle(2);
+ if (G.f & G_DEBUG) setlinestyle(2);
glBegin(GL_LINE_STRIP);
for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
@@ -381,14 +374,14 @@
}
glEnd();
- setlinestyle(0);
+ if (G.f & G_DEBUG) setlinestyle(0);
}
}
/* ----- Existing Strokes Drawing (3D and Point) ------ */
/* draw a given stroke - just a single dot (only one point) */
-static void gp_draw_stroke_point (bGPDspoint *points, short sflag, int winx, int winy)
+static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short sflag, int winx, int winy)
{
/* draw point */
if (sflag & GP_STROKE_3DSPACE) {
@@ -396,18 +389,38 @@
glVertex3f(points->x, points->y, points->z);
glEnd();
}
- else if (sflag & GP_STROKE_2DSPACE) {
- glBegin(GL_POINTS);
- glVertex2f(points->x, points->y);
- glEnd();
- }
else {
- const float x= (points->x / 1000 * winx);
- const float y= (points->y / 1000 * winy);
+ float co[2];
- glBegin(GL_POINTS);
- glVertex2f(x, y);
- glEnd();
+ /* get coordinates of point */
+ if (sflag & GP_STROKE_2DSPACE) {
+ co[0]= points->x;
+ co[1]= points->y;
+ }
+ else {
+ co[0]= (points->x / 1000 * winx);
+ co[1]= (points->y / 1000 * winy);
+ }
+
+ /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple opengl point will do */
+ if (thickness < GP_DRAWTHICKNESS_SPECIAL) {
+ glBegin(GL_POINTS);
+ glVertex2fv(co);
+ glEnd();
+ }
+ else {
+ /* draw filled circle as is done in circf (but without the matrix push/pops which screwed things up) */
+ GLUquadricObj *qobj = gluNewQuadric();
+
+ gluQuadricDrawStyle(qobj, GLU_FILL);
+
+ /* need to translate drawing position, but must reset after too! */
+ glTranslatef(co[0], co[1], 0.);
+ gluDisk( qobj, 0.0, thickness, 32, 1);
+ glTranslatef(-co[0], -co[1], 0.);
+
+ gluDeleteQuadric(qobj);
+ }
}
}
@@ -449,8 +462,8 @@
/* draw a given stroke in 2d */
static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy)
{
- /* if thickness is less than 3, 'smooth' opengl lines look better */
- if ((thickness < 3) || (G.rt==0)) {
+ /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better */
+ if (thickness < GP_DRAWTHICKNESS_SPECIAL) {
bGPDspoint *pt;
int i;
@@ -472,19 +485,15 @@
bGPDspoint *pt1, *pt2;
float pm[2];
int i;
- short n;
glShadeModel(GL_FLAT);
+ glBegin(GL_QUADS);
- glPointSize(3.0f); // temp
-
- for (n= 0; n < 2; n++) { // temp
- glBegin((n)?GL_POINTS:GL_QUADS);
-
for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) {
float s0[2], s1[2]; /* segment 'center' points */
float t0[2], t1[2]; /* tesselated coordinates */
float m1[2], m2[2]; /* gradient and normal */
+ float mt[2], sc[2]; /* gradient for thickness, point for end-cap */
float pthick; /* thickness at segment point */
/* get x and y coordinates from points */
@@ -502,42 +511,75 @@
/* calculate gradient and normal - 'angle'=(ny/nx) */
m1[1]= s1[1] - s0[1];
m1[0]= s1[0] - s0[0];
+ Normalize2(m1);
m2[1]= -m1[0];
m2[0]= m1[1];
- Normalize2(m2);
/* always use pressure from first point here */
pthick= (pt1->pressure * thickness);
/* if the first segment, start of segment is segment's normal */
if (i == 0) {
- // TODO: also draw/do a round end-cap first
+ /* draw start cap first
+ * - make points slightly closer to center (about halfway across)
+ */
+ mt[0]= m2[0] * pthick * 0.5;
+ mt[1]= m2[1] * pthick * 0.5;
+ sc[0]= s0[0] - (m1[0] * pthick * 0.75);
+ sc[1]= s0[1] - (m1[1] * pthick * 0.75);
+ t0[0]= sc[0] - mt[0];
+ t0[1]= sc[1] - mt[1];
+ t1[0]= sc[0] + mt[0];
+ t1[1]= sc[1] + mt[1];
+
+ glVertex2fv(t0);
+ glVertex2fv(t1);
+
/* calculate points for start of segment */
- t0[0]= s0[0] - (pthick * m2[0]);
- t0[1]= s0[1] - (pthick * m2[1]);
- t1[0]= s0[0] + (pthick * m2[0]);
- t1[1]= s0[1] + (pthick * m2[1]);
+ mt[0]= m2[0] * pthick;
+ mt[1]= m2[1] * pthick;
- /* draw this line only once */
+ t0[0]= s0[0] - mt[0];
+ t0[1]= s0[1] - mt[1];
+ t1[0]= s0[0] + mt[0];
+ t1[1]= s0[1] + mt[1];
+
+ /* draw this line twice (first to finish off start cap, then for stroke) */
+ glVertex2fv(t1);
glVertex2fv(t0);
+ glVertex2fv(t0);
glVertex2fv(t1);
}
/* if not the first segment, use bisector of angle between segments */
else {
- float mb[2]; /* bisector normal */
+ float mb[2]; /* bisector normal */
+ float athick, dfac; /* actual thickness, difference between thicknesses */
/* calculate gradient of bisector (as average of normals) */
mb[0]= (pm[0] + m2[0]) / 2;
mb[1]= (pm[1] + m2[1]) / 2;
Normalize2(mb);
+ /* calculate gradient to apply
+ * - as basis, use just pthick * bisector gradient
+ * - if cross-section not as thick as it should be, add extra padding to fix it
+ */
+ mt[0]= mb[0] * pthick;
+ mt[1]= mb[1] * pthick;
+ athick= Vec2Length(mt);
+ dfac= pthick - (athick * 2);
+ if ( ((athick * 2) < pthick) && (IS_EQ(athick, pthick)==0) )
+ {
+ mt[0] += (mb[0] * dfac);
+ mt[1] += (mb[1] * dfac);
+ }
+
/* calculate points for start of segment */
- // FIXME: do we need extra padding for acute angles?
- t0[0]= s0[0] - (pthick * mb[0]);
- t0[1]= s0[1] - (pthick * mb[1]);
- t1[0]= s0[0] + (pthick * mb[0]);
- t1[1]= s0[1] + (pthick * mb[1]);
+ t0[0]= s0[0] - mt[0];
+ t0[1]= s0[1] - mt[1];
+ t1[0]= s0[0] + mt[0];
+ t1[1]= s0[1] + mt[1];
/* draw this line twice (once for end of current segment, and once for start of next) */
glVertex2fv(t1);
@@ -552,16 +594,36 @@
pthick= (pt2->pressure * thickness);
/* calculate points for end of segment */
- t0[0]= s1[0] - (pthick * m2[0]);
- t0[1]= s1[1] - (pthick * m2[1]);
- t1[0]= s1[0] + (pthick * m2[0]);
- t1[1]= s1[1] + (pthick * m2[1]);
+ mt[0]= m2[0] * pthick;
+ mt[1]= m2[1] * pthick;
- /* draw this line only once */
+ t0[0]= s1[0] - mt[0];
+ t0[1]= s1[1] - mt[1];
+ t1[0]= s1[0] + mt[0];
+ t1[1]= s1[1] + mt[1];
+
+ /* draw this line twice (once for end of stroke, and once for endcap)*/
glVertex2fv(t1);
glVertex2fv(t0);
+ glVertex2fv(t0);
+ glVertex2fv(t1);
- // TODO: draw end cap as last step
+
+ /* draw end cap as last step
+ * - make points slightly closer to center (about halfway across)
+ */
+ mt[0]= m2[0] * pthick * 0.5;
+ mt[1]= m2[1] * pthick * 0.5;
+ sc[0]= s1[0] + (m1[0] * pthick * 0.75);
+ sc[1]= s1[1] + (m1[1] * pthick * 0.75);
+
+ t0[0]= sc[0] - mt[0];
+ t0[1]= sc[1] - mt[1];
+ t1[0]= sc[0] + mt[0];
+ t1[1]= sc[1] + mt[1];
+
+ glVertex2fv(t1);
+ glVertex2fv(t0);
}
/* store stroke's 'natural' normal for next stroke to use */
@@ -569,7 +631,6 @@
}
glEnd();
- }
}
/* draw debug points of curve on top? (original stroke points) */
@@ -623,7 +684,7 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list