Revision: 46616
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46616
Author:   campbellbarton
Date:     2012-05-13 21:36:42 +0000 (Sun, 13 May 2012)
Log Message:
-----------
style cleanup: mask, whitespace edits, also use len_squared_v2 for comparisons.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/raskter/raskter.c
    branches/soc-2011-tomato/intern/raskter/raskter.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/idcode.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/library.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h
    branches/soc-2011-tomato/source/blender/editors/include/ED_transform.h
    branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
    branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
    branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c

Modified: branches/soc-2011-tomato/intern/raskter/raskter.c
===================================================================
--- branches/soc-2011-tomato/intern/raskter/raskter.c   2012-05-13 18:59:10 UTC 
(rev 46615)
+++ branches/soc-2011-tomato/intern/raskter/raskter.c   2012-05-13 21:36:42 UTC 
(rev 46616)
@@ -32,8 +32,8 @@
 #include "raskter.h"
 
 // from BLI_utildefines.h
-#define MIN2(x,y)               ( (x)<(y) ? (x) : (y) )
-#define MAX2(x,y)               ( (x)>(y) ? (x) : (y) )
+#define MIN2(x, y)               ( (x) < (y) ? (x) : (y) )
+#define MAX2(x, y)               ( (x) > (y) ? (x) : (y) )
 
 
 struct e_status {
@@ -64,7 +64,7 @@
  * just the poly. Since the DEM code could end up being coupled with this, 
we'll keep it separate
  * for now.
  */
-static void preprocess_all_edges(struct poly_vert * verts, int num_verts, 
struct e_status * open_edge) {
+static void preprocess_all_edges(struct poly_vert *verts, int num_verts, 
struct e_status *open_edge) {
        int i;
        int xbeg;
        int ybeg;
@@ -82,21 +82,22 @@
        v = verts;
        all_edges = NULL;
        // loop all verts
-       for(i = 0; i < num_verts; i++) {
+       for (i = 0; i < num_verts; i++) {
                // determine beginnings and endings of edges, linking last 
vertex to first vertex
                xbeg = v[i].x;
                ybeg = v[i].y;
-               if(i) {
+               if (i) {
                        // we're not at the last vert, so end of the edge is 
the previous vertex
-                       xend = v[i-1].x;
-                       yend = v[i-1].y;
-               } else {
+                       xend = v[i - 1].x;
+                       yend = v[i - 1].y;
+               }
+               else {
                        // we're at the first vertex, so the "end" of this edge 
is the last vertex
-                       xend = v[num_verts-1].x;
-                       yend = v[num_verts-1].y;
+                       xend = v[num_verts - 1].x;
+                       yend = v[num_verts - 1].y;
                }
                // make sure our edges are facing the correct direction
-               if(ybeg > yend) {
+               if (ybeg > yend) {
                        // flip the Xs
                        temp_pos = xbeg;
                        xbeg = xend;
@@ -110,16 +111,17 @@
                // calculate y delta
                dy = yend - ybeg;
                // dont draw horizontal lines directly, they are scanned as 
part of the edges they connect, so skip em. :)
-               if(dy) {
+               if (dy) {
                        // create the edge and determine it's slope (for 
incremental line drawing)
                        e_new = open_edge++;
 
                        // calculate x delta
                        dx = xend - xbeg;
-                       if(dx > 0){
+                       if (dx > 0) {
                                e_new->xdir = 1;
                                xdist = dx;
-                       }else{
+                       }
+                       else {
                                e_new->xdir = -1;
                                xdist = -dx;
                        }
@@ -130,23 +132,25 @@
                        e_new->drift_dec = dy;
 
                        // calculate deltas for incremental drawing
-                       if(dx >= 0) {
+                       if (dx >= 0) {
                                e_new->drift = 0;
-                       } else {
+                       }
+                       else {
                                e_new->drift = -dy + 1;
                        }
-                       if(dy >= xdist) {
+                       if (dy >= xdist) {
                                e_new->drift_inc = xdist;
                                e_new->xshift = 0;
-                       } else {
+                       }
+                       else {
                                e_new->drift_inc = xdist % dy;
                                e_new->xshift = (xdist / dy) * e_new->xdir;
                        }
                        next_edge_ref = &all_edges;
                        // link in all the edges, in sorted order
-                       for(;;) {
+                       for (;; ) {
                                next_edge = *next_edge_ref;
-                               if(!next_edge || (next_edge->ybeg > ybeg) || 
((next_edge->ybeg == ybeg) && (next_edge->x >= xbeg))) {
+                               if (!next_edge || (next_edge->ybeg > ybeg) || 
((next_edge->ybeg == ybeg) && (next_edge->x >= xbeg))) {
                                        e_new->e_next = next_edge;
                                        *next_edge_ref = e_new;
                                        break;
@@ -162,156 +166,158 @@
  * for speed, but waiting on final design choices for curve-data before 
eliminating data the DEM code will need
  * if it ends up being coupled with this function.
  */
-int rast_scan_fill(struct poly_vert * verts, int num_verts) {
-       int x_curr;                                     // current pixel 
position in X
-       int y_curr;                                     // current scan line 
being drawn
-       int yp;                                         // y-pixel's position 
in frame buffer
-       int swixd = 0;                          // whether or not edges 
switched position in X
-       float *cpxl;                            // pixel pointers...
+int rast_scan_fill(struct poly_vert *verts, int num_verts) {
+       int x_curr;                 // current pixel position in X
+       int y_curr;                 // current scan line being drawn
+       int yp;                     // y-pixel's position in frame buffer
+       int swixd = 0;              // whether or not edges switched position 
in X
+       float *cpxl;                // pixel pointers...
        float *mpxl;
        float *spxl;
-       struct e_status *e_curr;        // edge pointers...
+       struct e_status *e_curr;    // edge pointers...
        struct e_status *e_temp;
        struct e_status *edgbuf;
        struct e_status **edgec;
 
 
        /*
-         If the number of verts specified to render as a polygon is less than 
3,
-         return immediately. Obviously we cant render a poly with sides < 3. 
The
-         return for this we set to 1, simply so it can be distinguished from 
the
-         next place we could return, which is a failure to allocate memory.
+          If the number of verts specified to render as a polygon is less than 
3,
+          return immediately. Obviously we cant render a poly with sides < 3. 
The
+          return for this we set to 1, simply so it can be distinguished from 
the
+          next place we could return, which is a failure to allocate memory.
         */
-       if(num_verts < 3) {
+       if (num_verts < 3) {
                return(1);
        }
 
        /*
-         Try to allocate an edge buffer in memory. needs to be the size of the 
edge tracking data
-         multiplied by the number of edges, which is always equal to the 
number of verts in
-         a 2D polygon. Here we return 0 to indicate a memory allocation 
failure, as opposed to a 1 for
-         the preceeding error, which was a rasterization request on a 2D poly 
with less than
-         3 sides.
+          Try to allocate an edge buffer in memory. needs to be the size of 
the edge tracking data
+          multiplied by the number of edges, which is always equal to the 
number of verts in
+          a 2D polygon. Here we return 0 to indicate a memory allocation 
failure, as opposed to a 1 for
+          the preceeding error, which was a rasterization request on a 2D poly 
with less than
+          3 sides.
         */
-       if((edgbuf = (struct e_status *)(malloc(sizeof(struct e_status) * 
num_verts))) == NULL) {
+       if ((edgbuf = (struct e_status *)(malloc(sizeof(struct e_status) * 
num_verts))) == NULL) {
                return(0);
        }
 
        /*
-         Do some preprocessing on all edges. This constructs a table structure 
in memory of all
-         the edge properties and can "flip" some edges so sorting works 
correctly.
+          Do some preprocessing on all edges. This constructs a table 
structure in memory of all
+          the edge properties and can "flip" some edges so sorting works 
correctly.
         */
        preprocess_all_edges(verts, num_verts, edgbuf);
 
        /*
-         Set the pointer for tracking the edges currently in processing to 
NULL to make sure
-         we don't get some crazy value after initialization.
+          Set the pointer for tracking the edges currently in processing to 
NULL to make sure
+          we don't get some crazy value after initialization.
         */
        possible_edges = NULL;
 
        /*
-         Loop through all scan lines to be drawn. Since we sorted by Y values 
during
-         preprocess_all_edges(), we can already exact values for the lowest and
-         highest Y values we could possibly need by induction. The 
preprocessing sorted
-         out edges by Y position, we can cycle the current edge being 
processed once
-         it runs out of Y pixels. When we have no more edges, meaning the 
current edge
-         is NULL after setting the "current" edge to be the previous current 
edge's
-         "next" edge in the Y sorted edge connection chain, we can stop 
looping Y values,
-         since we can't possibly have more scan lines if we ran out of edges. 
:)
+          Loop through all scan lines to be drawn. Since we sorted by Y values 
during
+          preprocess_all_edges(), we can already exact values for the lowest 
and
+          highest Y values we could possibly need by induction. The 
preprocessing sorted
+          out edges by Y position, we can cycle the current edge being 
processed once
+          it runs out of Y pixels. When we have no more edges, meaning the 
current edge
+          is NULL after setting the "current" edge to be the previous current 
edge's
+          "next" edge in the Y sorted edge connection chain, we can stop 
looping Y values,
+          since we can't possibly have more scan lines if we ran out of edges. 
:)
 
-         TODO: This clips Y to the frame buffer, which should be done in the 
preprocessor, but for now is done here.
-                       Will get changed once DEM code gets in.
+          TODO: This clips Y to the frame buffer, which should be done in the 
preprocessor, but for now is done here.
+               Will get changed once DEM code gets in.
         */
-       for(y_curr = MAX2(all_edges->ybeg,0); (all_edges || possible_edges) && 
(y_curr < rb.sizey); y_curr++) {
+       for (y_curr = MAX2(all_edges->ybeg, 0); (all_edges || possible_edges) 
&& (y_curr < rb.sizey); y_curr++) {
 
                /*
-                 Link any edges that start on the current scan line into the 
list of
-                 edges currently needed to draw at least this, if not several, 
scan lines.
+                  Link any edges that start on the current scan line into the 
list of
+                  edges currently needed to draw at least this, if not 
several, scan lines.
                 */
 
                /*
-                 Set the current edge to the beginning of the list of edges to 
be rasterized
-                 into this scan line.
+                  Set the current edge to the beginning of the list of edges 
to be rasterized
+                  into this scan line.
 
-                 We could have lots of edge here, so iterate over all the 
edges needed. The
-                 preprocess_all_edges() function sorted edges by X within each 
chunk of Y sorting
-                 so we safely cycle edges to thier own "next" edges in order.
+                  We could have lots of edge here, so iterate over all the 
edges needed. The
+                  preprocess_all_edges() function sorted edges by X within 
each chunk of Y sorting
+                  so we safely cycle edges to thier own "next" edges in order.
 
-                 At each iteration, make sure we still have a non-NULL edge.
+                  At each iteration, make sure we still have a non-NULL edge.
                 */
-               for(edgec = &possible_edges; all_edges && (all_edges->ybeg == 
y_curr);) {
+               for (edgec = &possible_edges; all_edges && (all_edges->ybeg == 
y_curr); ) {
                        x_curr = all_edges->x;                                
// Set current X position.
-                       for(;;) {                                             
// Start looping edges. Will break when edges run out.
+                       for (;; ) {                                             
// Start looping edges. Will break when edges run out.
                                e_curr = *edgec;                                
  // Set up a current edge pointer.
-                               if(!e_curr || (e_curr->x >= x_curr)) {          
  // If we have an no edge, or we need to skip some X-span,

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to