[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46433] trunk/blender/source/blender/ editors: style cleanup: gpencil & metaball
Campbell Barton
ideasman42 at gmail.com
Tue May 8 20:29:03 CEST 2012
Revision: 46433
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46433
Author: campbellbarton
Date: 2012-05-08 18:29:02 +0000 (Tue, 08 May 2012)
Log Message:
-----------
style cleanup: gpencil & metaball
Modified Paths:
--------------
trunk/blender/source/blender/editors/gpencil/drawgpencil.c
trunk/blender/source/blender/editors/gpencil/editaction_gpencil.c
trunk/blender/source/blender/editors/gpencil/gpencil_buttons.c
trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
trunk/blender/source/blender/editors/gpencil/gpencil_intern.h
trunk/blender/source/blender/editors/gpencil/gpencil_ops.c
trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
trunk/blender/source/blender/editors/gpencil/gpencil_undo.c
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_intern.h
trunk/blender/source/blender/editors/interface/interface_layout.c
trunk/blender/source/blender/editors/metaball/mball_edit.c
trunk/blender/source/blender/editors/metaball/mball_ops.c
trunk/blender/source/blender/editors/space_time/space_time.c
trunk/blender/source/blender/editors/space_time/time_ops.c
Modified: trunk/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/drawgpencil.c 2012-05-08 18:13:43 UTC (rev 46432)
+++ trunk/blender/source/blender/editors/gpencil/drawgpencil.c 2012-05-08 18:29:02 UTC (rev 46433)
@@ -74,23 +74,23 @@
/* flags for sflag */
typedef enum eDrawStrokeFlags {
- GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */
- GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */
- GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */
- GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */
- GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */
- GP_DRAWDATA_NO_XRAY = (1<<5), /* don't draw xray in 3D view (which is default) */
+ GP_DRAWDATA_NOSTATUS = (1 << 0), /* don't draw status info */
+ GP_DRAWDATA_ONLY3D = (1 << 1), /* only draw 3d-strokes */
+ GP_DRAWDATA_ONLYV2D = (1 << 2), /* only draw 'canvas' strokes */
+ GP_DRAWDATA_ONLYI2D = (1 << 3), /* only draw 'image' strokes */
+ GP_DRAWDATA_IEDITHACK = (1 << 4), /* special hack for drawing strokes in Image Editor (weird coordinates) */
+ GP_DRAWDATA_NO_XRAY = (1 << 5), /* don't draw xray in 3D view (which is default) */
} eDrawStrokeFlags;
/* thickness above which we should use special drawing */
-#define GP_DRAWTHICKNESS_SPECIAL 3
+#define GP_DRAWTHICKNESS_SPECIAL 3
/* ----- Tool Buffer Drawing ------ */
/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
-static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag)
+static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickness, short dflag, short sflag)
{
tGPspoint *pt;
int i;
@@ -100,14 +100,14 @@
return;
/* check if buffer can be drawn */
- if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D))
+ if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
return;
/* if drawing a single point, draw it larger */
if (totpoints == 1) {
/* draw point */
glBegin(GL_POINTS);
- glVertex2iv(&points->x);
+ glVertex2iv(&points->x);
glEnd();
}
else if (sflag & GP_STROKE_ERASER) {
@@ -122,7 +122,7 @@
glLineWidth(oldpressure * thickness);
glBegin(GL_LINE_STRIP);
- for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
+ for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
*/
@@ -154,12 +154,12 @@
/* ----- 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 thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
+static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
{
/* draw point */
if (sflag & GP_STROKE_3DSPACE) {
glBegin(GL_POINTS);
- glVertex3fv(&points->x);
+ glVertex3fv(&points->x);
glEnd();
}
else {
@@ -167,26 +167,26 @@
/* get coordinates of point */
if (sflag & GP_STROKE_2DSPACE) {
- co[0]= points->x;
- co[1]= points->y;
+ co[0] = points->x;
+ co[1] = points->y;
}
else if (sflag & GP_STROKE_2DIMAGE) {
- co[0]= (points->x * winx) + offsx;
- co[1]= (points->y * winy) + offsy;
+ co[0] = (points->x * winx) + offsx;
+ co[1] = (points->y * winy) + offsy;
}
else {
- co[0]= (points->x / 100 * winx) + offsx;
- co[1]= (points->y / 100 * winy) + offsy;
+ co[0] = (points->x / 100 * winx) + offsx;
+ co[1] = (points->y / 100 * winy) + offsy;
}
/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok
- * - also mandatory in if Image Editor 'image-based' dot
+ * - also mandatory in if Image Editor 'image-based' dot
*/
if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) ||
- ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) )
+ ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) )
{
glBegin(GL_POINTS);
- glVertex2fv(co);
+ glVertex2fv(co);
glEnd();
}
else {
@@ -206,7 +206,7 @@
}
/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
-static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short debug)
+static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug)
{
bGPDspoint *pt;
float oldpressure = 0.0f;
@@ -214,7 +214,7 @@
/* draw stroke curve */
glBegin(GL_LINE_STRIP);
- for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
+ for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
*/
@@ -240,7 +240,7 @@
/* draw debug points of curve on top? */
if (debug) {
glBegin(GL_POINTS);
- for (i=0, pt=points; i < totpoints && pt; i++, pt++)
+ for (i = 0, pt = points; i < totpoints && pt; i++, pt++)
glVertex3fv(&pt->x);
glEnd();
}
@@ -249,35 +249,35 @@
/* ----- Fancy 2D-Stroke Drawing ------ */
/* draw a given stroke in 2d */
-static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
- short debug, int offsx, int offsy, int winx, int winy)
+static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
+ short debug, int offsx, int offsy, int winx, int winy)
{
/* otherwise thickness is twice that of the 3D view */
- float thickness= (float)thickness_s * 0.5f;
+ float thickness = (float)thickness_s * 0.5f;
/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better
- * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke
+ * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke
*/
if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) ||
- ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) )
+ ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) )
{
bGPDspoint *pt;
int i;
glBegin(GL_LINE_STRIP);
- for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
+ for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
if (sflag & GP_STROKE_2DSPACE) {
glVertex2f(pt->x, pt->y);
}
else if (sflag & GP_STROKE_2DIMAGE) {
- const float x= (pt->x * winx) + offsx;
- const float y= (pt->y * winy) + offsy;
+ const float x = (pt->x * winx) + offsx;
+ const float y = (pt->y * winy) + offsy;
glVertex2f(x, y);
}
else {
- const float x= (pt->x / 100 * winx) + offsx;
- const float y= (pt->y / 100 * winy) + offsy;
+ const float x = (pt->x / 100 * winx) + offsx;
+ const float y = (pt->y / 100 * winy) + offsy;
glVertex2f(x, y);
}
@@ -296,67 +296,67 @@
glShadeModel(GL_FLAT);
glBegin(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]; /* tessellated 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 */
+ 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]; /* tessellated 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 */
if (sflag & GP_STROKE_2DSPACE) {
- s0[0]= pt1->x; s0[1]= pt1->y;
- s1[0]= pt2->x; s1[1]= pt2->y;
+ s0[0] = pt1->x; s0[1] = pt1->y;
+ s1[0] = pt2->x; s1[1] = pt2->y;
}
else if (sflag & GP_STROKE_2DIMAGE) {
- s0[0]= (pt1->x * winx) + offsx;
- s0[1]= (pt1->y * winy) + offsy;
- s1[0]= (pt2->x * winx) + offsx;
- s1[1]= (pt2->y * winy) + offsy;
+ s0[0] = (pt1->x * winx) + offsx;
+ s0[1] = (pt1->y * winy) + offsy;
+ s1[0] = (pt2->x * winx) + offsx;
+ s1[1] = (pt2->y * winy) + offsy;
}
else {
- s0[0]= (pt1->x / 100 * winx) + offsx;
- s0[1]= (pt1->y / 100 * winy) + offsy;
- s1[0]= (pt2->x / 100 * winx) + offsx;
- s1[1]= (pt2->y / 100 * winy) + offsy;
+ s0[0] = (pt1->x / 100 * winx) + offsx;
+ s0[1] = (pt1->y / 100 * winy) + offsy;
+ s1[0] = (pt2->x / 100 * winx) + offsx;
+ s1[1] = (pt2->y / 100 * winy) + offsy;
}
/* calculate gradient and normal - 'angle'=(ny/nx) */
- m1[1]= s1[1] - s0[1];
- m1[0]= s1[0] - s0[0];
+ m1[1] = s1[1] - s0[1];
+ m1[0] = s1[0] - s0[0];
normalize_v2(m1);
- m2[1]= -m1[0];
- m2[0]= m1[1];
+ m2[1] = -m1[0];
+ m2[0] = m1[1];
/* always use pressure from first point here */
- pthick= (pt1->pressure * thickness);
+ pthick = (pt1->pressure * thickness);
/* if the first segment, start of segment is segment's normal */
if (i == 0) {
/* draw start cap first
* - make points slightly closer to center (about halfway across)
*/
- mt[0]= m2[0] * pthick * 0.5f;
- mt[1]= m2[1] * pthick * 0.5f;
- sc[0]= s0[0] - (m1[0] * pthick * 0.75f);
- sc[1]= s0[1] - (m1[1] * pthick * 0.75f);
+ mt[0] = m2[0] * pthick * 0.5f;
+ mt[1] = m2[1] * pthick * 0.5f;
+ sc[0] = s0[0] - (m1[0] * pthick * 0.75f);
+ sc[1] = s0[1] - (m1[1] * pthick * 0.75f);
+
+ t0[0] = sc[0] - mt[0];
+ t0[1] = sc[1] - mt[1];
+ t1[0] = sc[0] + mt[0];
+ t1[1] = sc[1] + mt[1];
- 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 */
- mt[0]= m2[0] * pthick;
- mt[1]= m2[1] * pthick;
+ mt[0] = m2[0] * pthick;
+ mt[1] = m2[1] * pthick;
- t0[0]= s0[0] - mt[0];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list