16 |
|
int fl; |
17 |
|
uint4 xyz[3]; |
18 |
|
int4 norm; |
19 |
< |
int4 uv[2]; |
19 |
> |
uint4 uv[2]; |
20 |
|
} MCVERT; |
21 |
|
|
22 |
|
#define MPATCHBLKSIZ 128 /* patch allocation block size */ |
217 |
|
/* get (u,v) */ |
218 |
|
if (what & MT_UV && pp->uv != NULL && pp->uv[vid][0]) { |
219 |
|
for (i = 0; i < 2; i++) |
220 |
< |
vp->uv[i] = mp->uvlim[i][0] + |
221 |
< |
(mp->uvlim[i][1] - mp->uvlim[i][0])* |
220 |
> |
vp->uv[i] = mp->uvlim[0][i] + |
221 |
> |
(mp->uvlim[1][i] - mp->uvlim[0][i])* |
222 |
|
(pp->uv[vid][i] + .5)*(1./4294967296.); |
223 |
|
vp->fl |= MT_UV; |
224 |
|
} |
272 |
|
cv.norm = encodedir(vp->n); |
273 |
|
if (vp->fl & MT_UV) |
274 |
|
for (i = 0; i < 2; i++) { |
275 |
< |
if (vp->uv[i] <= mp->uvlim[i][0]) |
275 |
> |
if (vp->uv[i] <= mp->uvlim[0][i]) |
276 |
|
return(-1); |
277 |
< |
if (vp->uv[i] >= mp->uvlim[i][1]) |
277 |
> |
if (vp->uv[i] >= mp->uvlim[1][i]) |
278 |
|
return(-1); |
279 |
|
cv.uv[i] = (uint4)(4294967296. * |
280 |
< |
(vp->uv[i] - mp->uvlim[i][0]) / |
281 |
< |
(mp->uvlim[i][1] - mp->uvlim[i][0])); |
280 |
> |
(vp->uv[i] - mp->uvlim[0][i]) / |
281 |
> |
(mp->uvlim[1][i] - mp->uvlim[0][i])); |
282 |
|
} |
283 |
|
cv.fl = vp->fl; |
284 |
|
ltp = (LUTAB *)mp->cdata; /* get lookup table */ |
318 |
|
bzero((void *)(mp->patch + mp->npatches), |
319 |
|
MPATCHBLKSIZ*sizeof(MESHPATCH)); |
320 |
|
} |
321 |
< |
if (mp->npatches++ >= 1<<20) |
321 |
> |
if (mp->npatches++ >= 1L<<22) |
322 |
|
error(INTERNAL, "too many mesh patches"); |
323 |
|
} |
324 |
|
pp = &mp->patch[mp->npatches-1]; |
384 |
|
if (pp->tri == NULL) |
385 |
|
goto nomem; |
386 |
|
} |
387 |
< |
if (pp->ntris >= 512) |
388 |
< |
goto toomany; |
389 |
< |
pp->tri[pp->ntris].v1 = vid[0] & 0xff; |
390 |
< |
pp->tri[pp->ntris].v2 = vid[1] & 0xff; |
391 |
< |
pp->tri[pp->ntris].v3 = vid[2] & 0xff; |
392 |
< |
|
393 |
< |
return(pn[0] << 10 | pp->ntris++); |
387 |
> |
if (pp->ntris < 512) { |
388 |
> |
pp->tri[pp->ntris].v1 = vid[0] & 0xff; |
389 |
> |
pp->tri[pp->ntris].v2 = vid[1] & 0xff; |
390 |
> |
pp->tri[pp->ntris].v3 = vid[2] & 0xff; |
391 |
> |
return(pn[0] << 10 | pp->ntris++); |
392 |
> |
} |
393 |
|
} |
394 |
|
if (pn[0] == pn[1]) { |
395 |
< |
t = vid[2]; vid[2] = vid[0]; vid[0] = t; |
396 |
< |
i = pn[2]; pn[2] = pn[0]; pn[0] = i; |
395 |
> |
t = vid[2]; vid[2] = vid[1]; vid[1] = vid[0]; vid[0] = t; |
396 |
> |
i = pn[2]; pn[2] = pn[1]; pn[1] = pn[0]; pn[0] = i; |
397 |
|
} else if (pn[0] == pn[2]) { |
398 |
< |
t = vid[0]; vid[0] = vid[1]; vid[1] = t; |
399 |
< |
i = pn[0]; pn[0] = pn[1]; pn[1] = i; |
398 |
> |
t = vid[0]; vid[0] = vid[1]; vid[1] = vid[2]; vid[2] = t; |
399 |
> |
i = pn[0]; pn[0] = pn[1]; pn[1] = pn[2]; pn[2] = i; |
400 |
|
} |
401 |
|
if (pn[1] == pn[2]) { /* single link */ |
402 |
|
pp = &mp->patch[pn[1]]; |
406 |
|
if (pp->j1tri == NULL) |
407 |
|
goto nomem; |
408 |
|
} |
409 |
< |
if (pp->nj1tris >= 256) |
410 |
< |
goto toomany; |
411 |
< |
pp->j1tri[pp->nj1tris].v1j = pn[0] << 8 | (vid[0] & 0xff); |
412 |
< |
pp->j1tri[pp->nj1tris].v2 = vid[1] & 0xff; |
413 |
< |
pp->j1tri[pp->nj1tris].v3 = vid[2] & 0xff; |
414 |
< |
|
416 |
< |
return(pn[1] << 10 | 0x200 | pp->nj1tris++); |
409 |
> |
if (pp->nj1tris < 256) { |
410 |
> |
pp->j1tri[pp->nj1tris].v1j = vid[0]; |
411 |
> |
pp->j1tri[pp->nj1tris].v2 = vid[1] & 0xff; |
412 |
> |
pp->j1tri[pp->nj1tris].v3 = vid[2] & 0xff; |
413 |
> |
return(pn[1] << 10 | 0x200 | pp->nj1tris++); |
414 |
> |
} |
415 |
|
} |
416 |
|
/* double link */ |
417 |
|
pp = &mp->patch[pn[2]]; |
422 |
|
goto nomem; |
423 |
|
} |
424 |
|
if (pp->nj2tris >= 256) |
425 |
< |
goto toomany; |
426 |
< |
pp->j2tri[pp->nj2tris].v1j = pn[0] << 8 | (vid[0] & 0xff); |
427 |
< |
pp->j2tri[pp->nj2tris].v2j = pn[1] << 8 | (vid[1] & 0xff); |
425 |
> |
error(INTERNAL, "too many patch triangles in addmeshtri"); |
426 |
> |
pp->j2tri[pp->nj2tris].v1j = vid[0]; |
427 |
> |
pp->j2tri[pp->nj2tris].v2j = vid[1]; |
428 |
|
pp->j2tri[pp->nj2tris].v3 = vid[2] & 0xff; |
431 |
– |
|
429 |
|
return(pn[2] << 10 | 0x300 | pp->nj2tris++); |
430 |
|
nomem: |
431 |
|
error(SYSTEM, "out of memory in addmeshtri"); |
435 |
– |
return(OVOID); |
436 |
– |
toomany: |
437 |
– |
error(CONSISTENCY, "too many patch triangles in addmeshtri"); |
432 |
|
return(OVOID); |
433 |
|
} |
434 |
|
|