1 //////////////////////////////////////////////////////////////////////
2 //
3 //                             Pixie
4 //
5 // Copyright � 1999 - 2003, Okan Arikan
6 //
7 // Contact: okan@cs.utexas.edu
8 //
9 //	This library is free software; you can redistribute it and/or
10 //	modify it under the terms of the GNU Lesser General Public
11 //	License as published by the Free Software Foundation; either
12 //	version 2.1 of the License, or (at your option) any later version.
13 //
14 //	This library is distributed in the hope that it will be useful,
15 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
16 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 //	Lesser General Public License for more details.
18 //
19 //	You should have received a copy of the GNU Lesser General Public
20 //	License along with this library; if not, write to the Free Software
21 //	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 //
23 ///////////////////////////////////////////////////////////////////////
24 
25 // This is the portion of Pixie that draws a point into the zbuffer
26 
27 int			i;
28 const int	*bounds		=	grid->bounds;
29 const float	*vertices	=	grid->vertices;
30 const float	*sizes		=	grid->sizes;
31 const	int	xres		=	sampleWidth - 1;
32 const	int	yres		=	sampleHeight - 1;
33 
34 // Iterate over every quad
35 for (i=grid->numVertices;i>0;i--,vertices+=numVertexSamples,bounds+=4,sizes+=2) {
36 
37 	// Trivial rejects
38 	if (bounds[1] < left)		continue;
39 	if (bounds[3] < top)		continue;
40 	if (bounds[0] >= right)		continue;
41 	if (bounds[2] >= bottom)	continue;
42 
43 	int	xmin	=	bounds[0] - left;	// Convert the bound into the current bucket
44 	int	ymin	=	bounds[2] - top;
45 	int	xmax	=	bounds[1] - left;
46 	int	ymax	=	bounds[3] - top;
47 
48 	xmin		=	max(xmin,0);		// Clamp the bound in the current bucket
49 	ymin		=	max(ymin,0);
50 	xmax		=	min(xmax,xres);
51 	ymax		=	min(ymax,yres);
52 
53 
54 	float	xcent,ycent;
55 	int		x,y;
56 	for (		ycent=top+ymin+  0.5f,y=ymin;y<=ymax;y++,ycent++) {
57 		for (	xcent=left+xmin+ 0.5f,x=xmin;x<=xmax;x++,xcent++) {
58 
59 			const float dx				=	xcent - vertices[0];
60 			const float dy				=	ycent - vertices[1];
61 
62 			if ((dx*dx + dy*dy) < sizes[0]*sizes[0]) {
63 				float		*sample		=	&fb[y][x*SAMPLES_PER_PIXEL];
64 				const float	z			=	vertices[2];
65 
66 				if (z < sample[0] || (CRenderer::flags & RASTER_SHADE_HIDDEN)) {
67 					if (z > CRenderer::clipMin) {
68 						if (CRenderer::flags & RASTER_UNSHADED) {
69 							shadeGrid(grid,FALSE);
70 							rasterDrawPrimitives(grid);
71 							return;
72 						}
73 
74 						sample[0]	=	z;
75 						if (CRenderer::flags & RASTER_MATTE ) {
76 							initv(sample,0);
77 						} else {
78 							sample[1]	=	vertices[3];
79 							sample[2]	=	vertices[4];
80 							sample[3]	=	vertices[5];
81 						}
82 
83 						// Update the occlusion cache
84 						COcclusionNode	*cNode	=	getNode(x,y);
85 
86 						touchNode(cNode,z);
87 					}
88 				}
89 			}
90 		}
91 	}
92 }
93 
94