| 14 |
|
/* An encoded mesh vertex */ |
| 15 |
|
typedef struct { |
| 16 |
|
int fl; |
| 17 |
< |
uint4 xyz[3]; |
| 18 |
< |
int4 norm; |
| 19 |
< |
uint4 uv[2]; |
| 17 |
> |
uint32 xyz[3]; |
| 18 |
> |
int32 norm; |
| 19 |
> |
uint32 uv[2]; |
| 20 |
|
} MCVERT; |
| 21 |
|
|
| 22 |
|
#define MPATCHBLKSIZ 128 /* patch allocation block size */ |
| 94 |
|
ms->next = mlist; |
| 95 |
|
mlist = ms; |
| 96 |
|
} |
| 97 |
< |
if ((pathname = getpath(mname, getlibpath(), R_OK)) == NULL) { |
| 97 |
> |
if ((pathname = getpath(mname, getrlibpath(), R_OK)) == NULL) { |
| 98 |
|
sprintf(errmsg, "cannot find mesh file \"%s\"", mname); |
| 99 |
|
error(USER, errmsg); |
| 100 |
|
} |
| 136 |
|
|
| 137 |
|
int |
| 138 |
|
getmeshtrivid(tvid, mo, mp, ti) /* get triangle vertex ID's */ |
| 139 |
< |
int4 tvid[3]; |
| 139 |
> |
int32 tvid[3]; |
| 140 |
|
OBJECT *mo; |
| 141 |
|
MESH *mp; |
| 142 |
|
OBJECT ti; |
| 197 |
|
|
| 198 |
|
int |
| 199 |
|
getmeshvert(vp, mp, vid, what) /* get triangle vertex from ID */ |
| 200 |
< |
MESHVERT*vp; |
| 201 |
< |
MESH *mp; |
| 202 |
< |
int4 vid; |
| 203 |
< |
int what; |
| 200 |
> |
MESHVERT *vp; |
| 201 |
> |
MESH *mp; |
| 202 |
> |
int32 vid; |
| 203 |
> |
int what; |
| 204 |
|
{ |
| 205 |
|
int pn = vid >> 8; |
| 206 |
|
MESHPATCH *pp; |
| 269 |
|
OBJECT ti; |
| 270 |
|
int wha; |
| 271 |
|
{ |
| 272 |
< |
int4 tvid[3]; |
| 272 |
> |
int32 tvid[3]; |
| 273 |
|
|
| 274 |
|
if (!getmeshtrivid(tvid, mo, mp, ti)) |
| 275 |
|
return(0); |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
|
| 285 |
< |
int4 |
| 285 |
> |
int32 |
| 286 |
|
addmeshvert(mp, vp) /* find/add a mesh vertex */ |
| 287 |
|
register MESH *mp; |
| 288 |
|
MESHVERT *vp; |
| 299 |
|
return(-1); |
| 300 |
|
if (vp->v[i] >= mp->mcube.cuorg[i] + mp->mcube.cusize) |
| 301 |
|
return(-1); |
| 302 |
< |
cv.xyz[i] = (uint4)(4294967296. * |
| 302 |
> |
cv.xyz[i] = (uint32)(4294967296. * |
| 303 |
|
(vp->v[i] - mp->mcube.cuorg[i]) / |
| 304 |
|
mp->mcube.cusize); |
| 305 |
|
} |
| 311 |
|
return(-1); |
| 312 |
|
if (vp->uv[i] >= mp->uvlim[1][i]) |
| 313 |
|
return(-1); |
| 314 |
< |
cv.uv[i] = (uint4)(4294967296. * |
| 314 |
> |
cv.uv[i] = (uint32)(4294967296. * |
| 315 |
|
(vp->uv[i] - mp->uvlim[0][i]) / |
| 316 |
|
(mp->uvlim[1][i] - mp->uvlim[0][i])); |
| 317 |
|
} |
| 328 |
|
if (lvp == NULL) |
| 329 |
|
goto nomem; |
| 330 |
|
if (lvp->key == NULL) { |
| 331 |
< |
lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int4)); |
| 331 |
> |
lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32)); |
| 332 |
|
bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT)); |
| 333 |
|
} |
| 334 |
|
if (lvp->data == NULL) { /* new vertex */ |
| 353 |
|
} |
| 354 |
|
pp = &mp->patch[mp->npatches-1]; |
| 355 |
|
if (pp->xyz == NULL) { |
| 356 |
< |
pp->xyz = (uint4 (*)[3])calloc(256, 3*sizeof(int4)); |
| 356 |
> |
pp->xyz = (uint32 (*)[3])calloc(256, 3*sizeof(int32)); |
| 357 |
|
if (pp->xyz == NULL) |
| 358 |
|
goto nomem; |
| 359 |
|
} |
| 361 |
|
pp->xyz[pp->nverts][i] = cv.xyz[i]; |
| 362 |
|
if (cv.fl & MT_N) { |
| 363 |
|
if (pp->norm == NULL) { |
| 364 |
< |
pp->norm = (int4 *)calloc(256, sizeof(int4)); |
| 364 |
> |
pp->norm = (int32 *)calloc(256, sizeof(int32)); |
| 365 |
|
if (pp->norm == NULL) |
| 366 |
|
goto nomem; |
| 367 |
|
} |
| 369 |
|
} |
| 370 |
|
if (cv.fl & MT_UV) { |
| 371 |
|
if (pp->uv == NULL) { |
| 372 |
< |
pp->uv = (uint4 (*)[2])calloc(256, |
| 373 |
< |
2*sizeof(uint4)); |
| 372 |
> |
pp->uv = (uint32 (*)[2])calloc(256, |
| 373 |
> |
2*sizeof(uint32)); |
| 374 |
|
if (pp->uv == NULL) |
| 375 |
|
goto nomem; |
| 376 |
|
} |
| 379 |
|
} |
| 380 |
|
pp->nverts++; |
| 381 |
|
lvp->data = lvp->key + sizeof(MCVERT); |
| 382 |
< |
*(int4 *)lvp->data = (mp->npatches-1) << 8 | (pp->nverts-1); |
| 382 |
> |
*(int32 *)lvp->data = (mp->npatches-1) << 8 | (pp->nverts-1); |
| 383 |
|
} |
| 384 |
< |
return(*(int4 *)lvp->data); |
| 384 |
> |
return(*(int32 *)lvp->data); |
| 385 |
|
nomem: |
| 386 |
|
error(SYSTEM, "out of memory in addmeshvert"); |
| 387 |
|
return(-1); |
| 394 |
|
MESHVERT tv[3]; |
| 395 |
|
OBJECT mo; |
| 396 |
|
{ |
| 397 |
< |
int4 vid[3], t; |
| 397 |
> |
int32 vid[3], t; |
| 398 |
|
int pn[3], i; |
| 399 |
|
register MESHPATCH *pp; |
| 400 |
|
|
| 428 |
|
if (pp->ntris == 0) |
| 429 |
|
pp->solemat = mo; |
| 430 |
|
else if (pp->trimat == NULL && mo != pp->solemat) { |
| 431 |
< |
pp->trimat = (int2 *)malloc( |
| 432 |
< |
512*sizeof(int2)); |
| 431 |
> |
pp->trimat = (int16 *)malloc( |
| 432 |
> |
512*sizeof(int16)); |
| 433 |
|
if (pp->trimat == NULL) |
| 434 |
|
goto nomem; |
| 435 |
|
for (i = pp->ntris; i--; ) |
| 611 |
|
fprintf(fp, "\t%d materials\n", ms->nmats); |
| 612 |
|
fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches, |
| 613 |
|
(ms->npatches*sizeof(MESHPATCH) + |
| 614 |
< |
vcnt*3*sizeof(uint4) + |
| 615 |
< |
nscnt*sizeof(int4) + |
| 616 |
< |
uvscnt*2*sizeof(uint4) + |
| 614 |
> |
vcnt*3*sizeof(uint32) + |
| 615 |
> |
nscnt*sizeof(int32) + |
| 616 |
> |
uvscnt*2*sizeof(uint32) + |
| 617 |
|
tcnt*sizeof(struct PTri) + |
| 618 |
|
t1cnt*sizeof(struct PJoin1) + |
| 619 |
|
t2cnt*sizeof(struct PJoin2))/(1024.*1024.)); |