Changeset 3582 for trunk/src/opengl/mesa/clip_funcs.h
- Timestamp:
- May 21, 2000, 10:57:14 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/clip_funcs.h
r2938 r3582 1 /* $Id: clip_funcs.h,v 1. 1 2000-02-29 00:48:26 sandervlExp $ */1 /* $Id: clip_funcs.h,v 1.2 2000-05-21 20:15:38 jeroen Exp $ */ 2 2 3 3 /* … … 30 30 31 31 static GLuint TAG(userclip_line)( struct vertex_buffer *VB, 32 32 GLuint *i, GLuint *j ); 33 33 static GLuint TAG(userclip_polygon)( struct vertex_buffer *VB, 34 34 GLuint n, GLuint vlist[] ); 35 35 36 36 … … 39 39 */ 40 40 static GLuint TAG(viewclip_line)( struct vertex_buffer *VB, 41 42 41 GLuint *i, GLuint *j, 42 GLubyte mask ) 43 43 { 44 44 GLfloat (*coord)[4] = VB->ClipPtr->data; … … 55 55 * macros apprpriately. 56 56 */ 57 #define GENERAL_CLIP 58 if (mask & PLANE) { 59 GLuint flagI = INSIDE( ii ); 60 GLuint flagJ = INSIDE( jj ); 61 62 if (!(flagI|flagJ)) 63 return 0;\64 65 if (flagI ^ flagJ) { 66 COMPUTE_INTERSECTION( jj, ii, vb_free );\67 interp( VB, vb_free, t, jj, ii);\68 69 if (flagI) {\70 VB->ClipMask[jj] |= PLANE; 71 jj = vb_free;\72 } else {\73 VB->ClipMask[ii] |= PLANE; 74 ii = vb_free;\75 }\76 77 VB->ClipMask[vb_free++] = 0; 78 } 57 #define GENERAL_CLIP \ 58 if (mask & PLANE) { \ 59 GLuint flagI = INSIDE( ii ); \ 60 GLuint flagJ = INSIDE( jj ); \ 61 \ 62 if (!(flagI|flagJ)) \ 63 return 0; \ 64 \ 65 if (flagI ^ flagJ) { \ 66 COMPUTE_INTERSECTION( jj, ii, vb_free ); \ 67 interp( VB, vb_free, t, jj, ii); \ 68 \ 69 if (flagI) { \ 70 VB->ClipMask[jj] |= PLANE; \ 71 jj = vb_free; \ 72 } else { \ 73 VB->ClipMask[ii] |= PLANE; \ 74 ii = vb_free; \ 75 } \ 76 \ 77 VB->ClipMask[vb_free++] = 0; \ 78 } \ 79 79 } 80 80 … … 85 85 if (mask & CLIP_USER_BIT) { 86 86 if ( TAG(userclip_line)( VB, &ii, &jj ) == 0 ) 87 87 return 0; 88 88 } 89 89 … … 107 107 108 108 for (i = 0; i < n; i++) { 109 110 111 112 113 114 115 116 117 118 119 120 121 109 j = vlist[i]; 110 if (j >= start) { 111 if (W(j) != 0.0F) { 112 GLfloat wInv = 1.0F / W(j); 113 win[j][0] = X(j) * wInv * sx + tx; 114 win[j][1] = Y(j) * wInv * sy + ty; 115 win[j][2] = Z(j) * wInv * sz + tz; 116 win[j][3] = wInv; 117 } else { 118 win[j][0] = win[j][1] = win[j][2] = 0.0F; 119 win[j][3] = 1.0F; 120 } 121 } 122 122 } 123 123 } … … 138 138 */ 139 139 static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB, 140 141 140 GLuint n, GLuint vlist[], 141 GLubyte mask ) 142 142 { 143 143 GLfloat (*coord)[4] = VB->ClipPtr->data; … … 151 151 if (mask & CLIP_ALL_BITS) { 152 152 153 #define GENERAL_CLIP \ 154 if (mask & PLANE) { \ 155 GLuint prevj = inlist[n-1]; \ 156 GLuint prevflag = INSIDE(prevj); \ 157 GLuint outcount = 0; \ 158 GLuint ef_state = 3; \ 159 GLuint i; \ 160 \ 161 \ 162 for (i = 0; i < n; i++) { \ 163 GLuint j = inlist[i]; \ 164 GLuint flag = INSIDE(j); \ 165 \ 166 if (flag ^ prevflag) { \ 167 if (flag) { \ 168 /* Coming back in \ 169 */ \ 170 COMPUTE_INTERSECTION( j, prevj, vb_free ); \ 171 interp( VB, vb_free, t, j, prevj ); \ 172 \ 173 if (IND&CLIP_TAB_EDGEFLAG) \ 174 VB->EdgeFlagPtr->data[vb_free] = \ 175 VB->EdgeFlagPtr->data[prevj] & ef_state; \ 176 \ 177 \ 178 } else { \ 179 /* Going out of bounds \ 180 */ \ 181 COMPUTE_INTERSECTION( prevj, j, vb_free ); \ 182 interp( VB, vb_free, t, prevj, j ); \ 183 \ 184 if (IND&CLIP_TAB_EDGEFLAG) \ 185 VB->EdgeFlagPtr->data[vb_free] = 1; \ 186 } \ 187 \ 188 outlist[outcount++] = vb_free; \ 189 VB->ClipMask[vb_free++] = 0; \ 190 } \ 191 \ 192 if (flag) { \ 193 outlist[outcount++] = j; \ 194 } else { \ 195 VB->ClipMask[j] |= (PLANE&CLIP_ALL_BITS); /* don't setup */ \ 196 } \ 197 prevj = j; \ 198 prevflag = flag; \ 199 ef_state = 1; \ 200 } \ 201 \ 202 if (outcount < 3) \ 203 return 0; \ 204 else { \ 205 GLuint *tmp = inlist; \ 206 inlist = outlist; \ 207 outlist = tmp; \ 208 n = outcount; \ 209 } \ 153 #define GENERAL_CLIP \ 154 if (mask & PLANE) { \ 155 GLuint prevj = inlist[0]; \ 156 GLuint prevflag = INSIDE(prevj); \ 157 GLuint outcount = 0; \ 158 GLuint i; \ 159 \ 160 inlist[n] = inlist[0]; \ 161 \ 162 for (i = 1; i < n+1; i++) { \ 163 GLuint j = inlist[i]; \ 164 GLuint flag = INSIDE(j); \ 165 \ 166 if (prevflag) { \ 167 outlist[outcount++] = prevj; \ 168 } else { \ 169 VB->ClipMask[prevj] |= (PLANE&CLIP_ALL_BITS); \ 170 } \ 171 \ 172 if (flag ^ prevflag) { \ 173 if (flag) { \ 174 /* Coming back in \ 175 */ \ 176 COMPUTE_INTERSECTION( j, prevj, vb_free ); \ 177 interp( VB, vb_free, t, j, prevj ); \ 178 \ 179 if (IND&CLIP_TAB_EDGEFLAG) \ 180 VB->EdgeFlagPtr->data[vb_free] = \ 181 VB->EdgeFlagPtr->data[prevj]; \ 182 \ 183 \ 184 } else { \ 185 /* Going out of bounds \ 186 */ \ 187 COMPUTE_INTERSECTION( prevj, j, vb_free ); \ 188 interp( VB, vb_free, t, prevj, j ); \ 189 \ 190 if (IND&CLIP_TAB_EDGEFLAG) { \ 191 VB->EdgeFlagPtr->data[vb_free] = 3; \ 192 } \ 193 } \ 194 \ 195 if (IND&CLIP_TAB_EDGEFLAG) { \ 196 /* Demote trailing edge to internal edge. \ 197 */ \ 198 if (outcount && \ 199 (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2)) \ 200 VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1; \ 201 } \ 202 \ 203 outlist[outcount++] = vb_free; \ 204 VB->ClipMask[vb_free++] = 0; \ 205 } \ 206 \ 207 prevj = j; \ 208 prevflag = flag; \ 209 } \ 210 \ 211 if (outcount < 3) \ 212 return 0; \ 213 else { \ 214 GLuint *tmp = inlist; \ 215 inlist = outlist; \ 216 outlist = tmp; \ 217 n = outcount; \ 218 } \ 210 219 } 211 220 … … 214 223 215 224 if (inlist != vlist) 216 217 225 for (i = 0 ; i < n ; i++) 226 vlist[i] = inlist[i]; 218 227 } 219 228 … … 241 250 242 251 for (i = 0; i < n; i++) { 243 244 245 246 247 248 249 250 251 252 253 254 255 252 GLuint j = vlist[i]; 253 if (j >= first) { 254 if (W(j) != 0.0F) { 255 GLfloat wInv = 1.0F / W(j); 256 win[j][0] = X(j) * wInv * sx + tx; 257 win[j][1] = Y(j) * wInv * sy + ty; 258 win[j][2] = Z(j) * wInv * sz + tz; 259 win[j][3] = wInv; 260 } else { 261 win[j][0] = win[j][1] = win[j][2] = 0.0; 262 win[j][3] = 1.0F; 263 } 264 } 256 265 } 257 266 } … … 271 280 272 281 static GLuint TAG(userclip_line)( struct vertex_buffer *VB, 273 282 GLuint *i, GLuint *j ) 274 283 { 275 284 GLcontext *ctx = VB->ctx; … … 283 292 for (p=0;p<MAX_CLIP_PLANES;p++) { 284 293 if (ctx->Transform.ClipEnabled[p]) { 285 286 287 288 289 290 291 294 GLfloat a = ctx->Transform.ClipUserPlane[p][0]; 295 GLfloat b = ctx->Transform.ClipUserPlane[p][1]; 296 GLfloat c = ctx->Transform.ClipUserPlane[p][2]; 297 GLfloat d = ctx->Transform.ClipUserPlane[p][3]; 298 299 GLfloat dpI = d*W(ii) + c*Z(ii) + b*Y(ii) + a*X(ii); 300 GLfloat dpJ = d*W(jj) + c*Z(jj) + b*Y(jj) + a*X(jj); 292 301 293 302 GLuint flagI = OUTSIDE( dpI ); 294 303 GLuint flagJ = OUTSIDE( dpJ ); 295 304 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 305 if (flagI & flagJ) 306 return 0; 307 308 if (flagI ^ flagJ) { 309 GLfloat t = -dpI/(dpJ-dpI); 310 311 INTERP_SZ( t, coord, vb_free, ii, jj, SIZE ); 312 interp( VB, vb_free, t, ii, jj ); 313 314 if (flagI) { 315 VB->ClipMask[ii] |= CLIP_USER_BIT; 316 ii = vb_free; 317 } else { 318 VB->ClipMask[jj] |= CLIP_USER_BIT; 319 jj = vb_free; 320 } 321 322 VB->ClipMask[vb_free++] = 0; 314 323 } 315 324 } … … 324 333 325 334 static GLuint TAG(userclip_polygon)( struct vertex_buffer *VB, 326 335 GLuint n, GLuint vlist[] ) 327 336 { 328 337 GLcontext *ctx = VB->ctx; … … 336 345 for (p=0;p<MAX_CLIP_PLANES;p++) { 337 346 if (ctx->Transform.ClipEnabled[p]) { 338 register float a = ctx->Transform.ClipUserPlane[p][0]; 339 register float b = ctx->Transform.ClipUserPlane[p][1]; 340 register float c = ctx->Transform.ClipUserPlane[p][2]; 341 register float d = ctx->Transform.ClipUserPlane[p][3]; 342 343 /* initialize prev to be last in the input list */ 344 GLuint prevj = inlist[n - 1]; 345 GLfloat dpJ = d*W(prevj) + c*Z(prevj) + b*Y(prevj) + a*X(prevj); 346 GLuint flagJ = INSIDE(dpJ); 347 GLuint outcount = 0; 348 GLuint curri; 349 350 for (curri=0;curri<n;curri++) { 351 GLuint currj = inlist[curri]; 352 GLfloat dpI = d*W(currj) + c*Z(currj) + b*Y(currj) + a*X(currj); 347 register float a = ctx->Transform.ClipUserPlane[p][0]; 348 register float b = ctx->Transform.ClipUserPlane[p][1]; 349 register float c = ctx->Transform.ClipUserPlane[p][2]; 350 register float d = ctx->Transform.ClipUserPlane[p][3]; 351 352 /* initialize prev to be last in the input list */ 353 GLuint prevj = inlist[0]; 354 GLfloat dpJ = d*W(prevj) + c*Z(prevj) + b*Y(prevj) + a*X(prevj); 355 GLuint flagJ = INSIDE(dpJ); 356 GLuint outcount = 0; 357 GLuint curri; 358 359 inlist[n] = inlist[0]; 360 361 362 for (curri=1;curri<n+1;curri++) { 363 GLuint currj = inlist[curri]; 364 GLfloat dpI = d*W(currj) + c*Z(currj) + b*Y(currj) + a*X(currj); 353 365 GLuint flagI = INSIDE(dpI); 354 366 355 if (flagI ^ flagJ) { 356 GLfloat t; 357 GLuint in; 358 GLuint out; 359 360 if (flagI) { 361 out = prevj; 367 if (flagJ) { 368 outlist[outcount++] = prevj; 369 } else { 370 VB->ClipMask[prevj] |= CLIP_USER_BIT; 371 } 372 373 if (flagI ^ flagJ) { 374 GLfloat t; 375 GLuint in; 376 GLuint out; 377 378 if (flagI) { 379 out = prevj; 362 380 in = currj; 363 381 t = dpI/(dpI-dpJ); 364 382 365 366 367 368 369 383 if (IND&CLIP_TAB_EDGEFLAG) 384 VB->EdgeFlagPtr->data[vb_free] = 385 VB->EdgeFlagPtr->data[prevj]; 386 } else { 387 in = prevj; 370 388 out = currj; 371 389 t = dpJ/(dpJ-dpI); 372 390 373 if (IND&CLIP_TAB_EDGEFLAG) 374 VB->EdgeFlagPtr->data[vb_free] = 1; 375 } 376 377 INTERP_SZ( t, coord, vb_free, in, out, SIZE ); 378 interp( VB, vb_free, t, in, out); 379 outlist[outcount++] = vb_free; 380 VB->ClipMask[vb_free++] = 0; 391 if (IND&CLIP_TAB_EDGEFLAG) 392 VB->EdgeFlagPtr->data[vb_free] = 1; 393 } 394 395 if (IND&CLIP_TAB_EDGEFLAG) { 396 /* Demote trailing edge to internal edge. 397 */ 398 if (outcount && 399 (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2)) 400 VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1; 401 } 402 403 INTERP_SZ( t, coord, vb_free, in, out, SIZE ); 404 interp( VB, vb_free, t, in, out); 405 outlist[outcount++] = vb_free; 406 VB->ClipMask[vb_free++] = 0; 381 407 } 382 408 383 if (flagI) { 384 outlist[outcount++] = currj; 385 } else { 386 VB->ClipMask[currj] |= CLIP_USER_BIT; 387 } 388 389 prevj = currj; 390 flagJ = flagI; 391 dpJ = dpI; 409 prevj = currj; 410 flagJ = flagI; 411 dpJ = dpI; 392 412 } 393 413 394 395 396 414 if (outcount < 3) 415 return 0; 416 else { 397 417 GLuint *tmp; 398 418 tmp = inlist; … … 408 428 GLuint i; 409 429 for (i = 0 ; i < n ; i++) 410 430 vlist[i] = inlist[i]; 411 431 } 412 432
Note:
See TracChangeset
for help on using the changeset viewer.