[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50643] trunk/blender/intern/raskter/ raskter.c: code cleanup: remove unused structs and also some style cleanup.
Campbell Barton
ideasman42 at gmail.com
Sun Sep 16 01:13:25 CEST 2012
Revision: 50643
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50643
Author: campbellbarton
Date: 2012-09-15 23:13:24 +0000 (Sat, 15 Sep 2012)
Log Message:
-----------
code cleanup: remove unused structs and also some style cleanup.
Modified Paths:
--------------
trunk/blender/intern/raskter/raskter.c
Modified: trunk/blender/intern/raskter/raskter.c
===================================================================
--- trunk/blender/intern/raskter/raskter.c 2012-09-15 23:05:34 UTC (rev 50642)
+++ trunk/blender/intern/raskter/raskter.c 2012-09-15 23:13:24 UTC (rev 50643)
@@ -24,6 +24,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+
/** \file raskter.c
* \ingroup RASKTER
*/
@@ -36,62 +37,38 @@
#define MAX2(x, y) ( (x) > (y) ? (x) : (y) )
#define ABS(a) ( (a) < 0 ? (-(a)) : (a) )
-struct poly_vert {
- int x;
- int y;
+struct PolyVert {
+ int x;
+ int y;
};
-struct scan_line {
- int xstart;
- int xend;
+struct e_Status {
+ int x;
+ int ybeg;
+ int xshift;
+ int xdir;
+ int drift;
+ int drift_inc;
+ int drift_dec;
+ int num;
+ struct e_Status *e_next;
};
-struct scan_line_batch {
- int num;
- int ystart;
- struct scan_line *slines;
+struct r_BufferStats {
+ float *buf;
+ int sizex;
+ int sizey;
+ int ymin;
+ int ymax;
+ int xmin;
+ int xmax;
};
-struct e_status {
- int x;
- int ybeg;
- int xshift;
- int xdir;
- int drift;
- int drift_inc;
- int drift_dec;
- int num;
- struct e_status *e_next;
+struct r_FillContext {
+ struct e_Status *all_edges, *possible_edges;
+ struct r_BufferStats rb;
};
-struct r_buffer_stats {
- float *buf;
- int sizex;
- int sizey;
- int ymin;
- int ymax;
- int xmin;
- int xmax;
-};
-
-struct r_fill_context {
- struct e_status *all_edges, *possible_edges;
- struct r_buffer_stats rb;
- struct scan_line *bounds;
- void *kdo; //only used with kd tree
- void *kdi; //only used with kd tree
- int *bound_indexes;
- int bounds_length;
-};
-
-struct layer_init_data {
- struct poly_vert *imask;
- struct poly_vert *omask;
- struct scan_line *bounds;
- int *bound_indexes;
- int bounds_length;
-};
-
/*
* Sort all the edges of the input polygon by Y, then by X, of the "first" vertex encountered.
* This will ensure we can scan convert the entire poly in one pass.
@@ -100,113 +77,121 @@
* 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 r_fill_context *ctx, struct poly_vert *verts, int num_verts, struct e_status *open_edge) {
- int i;
- int xbeg;
- int ybeg;
- int xend;
- int yend;
- int dx;
- int dy;
- int temp_pos;
- int xdist;
- struct e_status *e_new;
- struct e_status *next_edge;
- struct e_status **next_edge_ref;
- struct poly_vert *v;
- /* set up pointers */
- v = verts;
- ctx->all_edges = NULL;
- /* initialize some boundaries */
- ctx->rb.xmax = v[0].x;
- ctx->rb.xmin = v[0].x;
- ctx->rb.ymax = v[0].y;
- ctx->rb.ymin = v[0].y;
- /* loop all verts */
- 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;
- /* keep track of our x and y bounds */
- if(xbeg >= ctx->rb.xmax) {
- ctx->rb.xmax = xbeg;
- } else if(xbeg <= ctx->rb.xmin) {
- ctx->rb.xmin = xbeg;
- }
- if(ybeg >= ctx->rb.ymax) {
- ctx->rb.ymax= ybeg;
- } else if(ybeg <= ctx->rb.ymin) {
- ctx->rb.ymin=ybeg;
- }
- 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 {
- /* 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;
- }
- /* make sure our edges are facing the correct direction */
- if(ybeg > yend) {
- /* flip the Xs */
- temp_pos = xbeg;
- xbeg = xend;
- xend = temp_pos;
- /* flip the Ys */
- temp_pos = ybeg;
- ybeg = yend;
- yend = temp_pos;
- }
+static void preprocess_all_edges(struct r_FillContext *ctx,
+ struct PolyVert *verts, int num_verts, struct e_Status *open_edge)
+{
+ int i;
+ int xbeg;
+ int ybeg;
+ int xend;
+ int yend;
+ int dx;
+ int dy;
+ int temp_pos;
+ int xdist;
+ struct e_Status *e_new;
+ struct e_Status *next_edge;
+ struct e_Status **next_edge_ref;
+ struct PolyVert *v;
+ /* set up pointers */
+ v = verts;
+ ctx->all_edges = NULL;
+ /* initialize some boundaries */
+ ctx->rb.xmax = v[0].x;
+ ctx->rb.xmin = v[0].x;
+ ctx->rb.ymax = v[0].y;
+ ctx->rb.ymin = v[0].y;
+ /* loop all verts */
+ 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;
+ /* keep track of our x and y bounds */
+ if (xbeg >= ctx->rb.xmax) {
+ ctx->rb.xmax = xbeg;
+ }
+ else if (xbeg <= ctx->rb.xmin) {
+ ctx->rb.xmin = xbeg;
+ }
+ if (ybeg >= ctx->rb.ymax) {
+ ctx->rb.ymax= ybeg;
+ }
+ else if (ybeg <= ctx->rb.ymin) {
+ ctx->rb.ymin=ybeg;
+ }
+ 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 {
+ /* 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;
+ }
+ /* make sure our edges are facing the correct direction */
+ if (ybeg > yend) {
+ /* flip the Xs */
+ temp_pos = xbeg;
+ xbeg = xend;
+ xend = temp_pos;
+ /* flip the Ys */
+ temp_pos = ybeg;
+ ybeg = yend;
+ yend = temp_pos;
+ }
- /* 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) {
- /* create the edge and determine it's slope (for incremental line drawing) */
- e_new = open_edge++;
+ /* 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) {
+ /* 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) {
- e_new->xdir = 1;
- xdist = dx;
- } else {
- e_new->xdir = -1;
- xdist = -dx;
- }
+ /* calculate x delta */
+ dx = xend - xbeg;
+ if (dx > 0) {
+ e_new->xdir = 1;
+ xdist = dx;
+ }
+ else {
+ e_new->xdir = -1;
+ xdist = -dx;
+ }
- e_new->x = xbeg;
- e_new->ybeg = ybeg;
- e_new->num = dy;
- e_new->drift_dec = dy;
+ e_new->x = xbeg;
+ e_new->ybeg = ybeg;
+ e_new->num = dy;
+ e_new->drift_dec = dy;
- /* calculate deltas for incremental drawing */
- if(dx >= 0) {
- e_new->drift = 0;
- } else {
- e_new->drift = -dy + 1;
- }
- if(dy >= xdist) {
- e_new->drift_inc = xdist;
- e_new->xshift = 0;
- } else {
- e_new->drift_inc = xdist % dy;
- e_new->xshift = (xdist / dy) * e_new->xdir;
- }
- next_edge_ref = &ctx->all_edges;
- /* link in all the edges, in sorted order */
- for(;;) {
- next_edge = *next_edge_ref;
- 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;
- }
- next_edge_ref = &next_edge->e_next;
- }
- }
- }
+ /* calculate deltas for incremental drawing */
+ if (dx >= 0) {
+ e_new->drift = 0;
+ }
+ else {
+ e_new->drift = -dy + 1;
+ }
+ if (dy >= xdist) {
+ e_new->drift_inc = xdist;
+ e_new->xshift = 0;
+ }
+ else {
+ e_new->drift_inc = xdist % dy;
+ e_new->xshift = (xdist / dy) * e_new->xdir;
+ }
+ next_edge_ref = &ctx->all_edges;
+ /* link in all the edges, in sorted order */
+ for (;;) {
+ next_edge = *next_edge_ref;
+ 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;
+ }
+ next_edge_ref = &next_edge->e_next;
+ }
+ }
+ }
}
/*
@@ -214,257 +199,260 @@
* 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.
*/
-static int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float intensity) {
- 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_temp;
- struct e_status *edgbuf;
- struct e_status **edgec;
+static int rast_scan_fill(struct r_FillContext *ctx, struct PolyVert *verts, int num_verts, float intensity)
+{
+ 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_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, /home/guest/blender-svn/soc-2011-tomato/intern/raskter/raskter.
- * which is a failure to allocate memory.
- */
- if(num_verts < 3) {
- return(1);
- }
+ /*
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list