| 32 |
|
|
| 33 |
|
|
| 34 |
|
static unsigned long |
| 35 |
< |
cvhash(cvp) /* hash an encoded vertex */ |
| 36 |
< |
MCVERT *cvp; |
| 35 |
> |
cvhash(const char *p) /* hash an encoded vertex */ |
| 36 |
|
{ |
| 37 |
+ |
const MCVERT *cvp = (const MCVERT *)p; |
| 38 |
|
unsigned long hval; |
| 39 |
|
|
| 40 |
|
if (!(cvp->fl & MT_V)) |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
static int |
| 52 |
< |
cvcmp(v1, v2) /* compare encoded vertices */ |
| 53 |
< |
register MCVERT *v1, *v2; |
| 52 |
> |
cvcmp(const char *vv1, const char *vv2) /* compare encoded vertices */ |
| 53 |
|
{ |
| 54 |
+ |
const MCVERT *v1 = (const MCVERT *)vv1, *v2 = (const MCVERT *)vv2; |
| 55 |
|
if (v1->fl != v2->fl) |
| 56 |
|
return(1); |
| 57 |
|
if (v1->xyz[0] != v2->xyz[0]) |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
MESH * |
| 76 |
< |
getmesh(mname, flags) /* get new mesh data reference */ |
| 77 |
< |
char *mname; |
| 78 |
< |
int flags; |
| 76 |
> |
getmesh( /* get new mesh data reference */ |
| 77 |
> |
char *mname, |
| 78 |
> |
int flags |
| 79 |
> |
) |
| 80 |
|
{ |
| 81 |
|
char *pathname; |
| 82 |
< |
register MESH *ms; |
| 82 |
> |
MESH *ms; |
| 83 |
|
|
| 84 |
|
flags &= IO_LEGAL; |
| 85 |
|
for (ms = mlist; ms != NULL; ms = ms->next) |
| 99 |
|
} |
| 100 |
|
if ((pathname = getpath(mname, getrlibpath(), R_OK)) == NULL) { |
| 101 |
|
sprintf(errmsg, "cannot find mesh file \"%s\"", mname); |
| 102 |
< |
error(USER, errmsg); |
| 102 |
> |
error(SYSTEM, errmsg); |
| 103 |
|
} |
| 104 |
|
flags &= ~ms->ldflags; |
| 105 |
|
if (flags) |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
MESHINST * |
| 112 |
< |
getmeshinst(o, flags) /* create mesh instance */ |
| 113 |
< |
OBJREC *o; |
| 114 |
< |
int flags; |
| 112 |
> |
getmeshinst( /* create mesh instance */ |
| 113 |
> |
OBJREC *o, |
| 114 |
> |
int flags |
| 115 |
> |
) |
| 116 |
|
{ |
| 117 |
< |
register MESHINST *ins; |
| 117 |
> |
MESHINST *ins; |
| 118 |
|
|
| 119 |
|
flags &= IO_LEGAL; |
| 120 |
|
if ((ins = (MESHINST *)o->os) == NULL) { |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
int |
| 146 |
< |
getmeshtrivid(tvid, mo, mp, ti) /* get triangle vertex ID's */ |
| 147 |
< |
int32 tvid[3]; |
| 148 |
< |
OBJECT *mo; |
| 149 |
< |
MESH *mp; |
| 148 |
< |
OBJECT ti; |
| 146 |
> |
nextmeshtri( /* get next triangle ID */ |
| 147 |
> |
OBJECT *tip, |
| 148 |
> |
MESH *mp |
| 149 |
> |
) |
| 150 |
|
{ |
| 151 |
+ |
int pn; |
| 152 |
+ |
MESHPATCH *pp; |
| 153 |
+ |
|
| 154 |
+ |
pn = ++(*tip) >> 10; /* next triangle (OVOID init) */ |
| 155 |
+ |
while (pn < mp->npatches) { |
| 156 |
+ |
pp = &mp->patch[pn]; |
| 157 |
+ |
if (!(*tip & 0x200)) { /* local triangle? */ |
| 158 |
+ |
if ((*tip & 0x1ff) < pp->ntris) |
| 159 |
+ |
return(1); |
| 160 |
+ |
*tip &= ~0x1ff; /* move on to single-joiners */ |
| 161 |
+ |
*tip |= 0x200; |
| 162 |
+ |
} |
| 163 |
+ |
if (!(*tip & 0x100)) { /* single joiner? */ |
| 164 |
+ |
if ((*tip & 0xff) < pp->nj1tris) |
| 165 |
+ |
return(1); |
| 166 |
+ |
*tip &= ~0xff; /* move on to double-joiners */ |
| 167 |
+ |
*tip |= 0x100; |
| 168 |
+ |
} |
| 169 |
+ |
if ((*tip & 0xff) < pp->nj2tris) |
| 170 |
+ |
return(1); |
| 171 |
+ |
*tip = ++pn << 10; /* first in next patch */ |
| 172 |
+ |
} |
| 173 |
+ |
return(0); /* out of patches */ |
| 174 |
+ |
} |
| 175 |
+ |
|
| 176 |
+ |
int |
| 177 |
+ |
getmeshtrivid( /* get triangle vertex ID's */ |
| 178 |
+ |
int32 tvid[3], |
| 179 |
+ |
OBJECT *mo, |
| 180 |
+ |
MESH *mp, |
| 181 |
+ |
OBJECT ti |
| 182 |
+ |
) |
| 183 |
+ |
{ |
| 184 |
|
int pn = ti >> 10; |
| 185 |
|
MESHPATCH *pp; |
| 186 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
int |
| 239 |
< |
getmeshvert(vp, mp, vid, what) /* get triangle vertex from ID */ |
| 240 |
< |
MESHVERT *vp; |
| 241 |
< |
MESH *mp; |
| 242 |
< |
int32 vid; |
| 243 |
< |
int what; |
| 239 |
> |
getmeshvert( /* get triangle vertex from ID */ |
| 240 |
> |
MESHVERT *vp, |
| 241 |
> |
MESH *mp, |
| 242 |
> |
int32 vid, |
| 243 |
> |
int what |
| 244 |
> |
) |
| 245 |
|
{ |
| 246 |
|
int pn = vid >> 8; |
| 247 |
|
MESHPATCH *pp; |
| 248 |
|
double vres; |
| 249 |
< |
register int i; |
| 249 |
> |
int i; |
| 250 |
|
|
| 251 |
|
vp->fl = 0; |
| 252 |
|
if (pn >= mp->npatches) |
| 281 |
|
|
| 282 |
|
|
| 283 |
|
OBJREC * |
| 284 |
< |
getmeshpseudo(mp, mo) /* get mesh pseudo object for material */ |
| 285 |
< |
MESH *mp; |
| 286 |
< |
OBJECT mo; |
| 284 |
> |
getmeshpseudo( /* get mesh pseudo object for material */ |
| 285 |
> |
MESH *mp, |
| 286 |
> |
OBJECT mo |
| 287 |
> |
) |
| 288 |
|
{ |
| 289 |
|
if (mo < mp->mat0 || mo >= mp->mat0 + mp->nmats) |
| 290 |
|
error(INTERNAL, "modifier out of range in getmeshpseudo"); |
| 291 |
|
if (mp->pseudo == NULL) { |
| 292 |
< |
register int i; |
| 292 |
> |
int i; |
| 293 |
|
mp->pseudo = (OBJREC *)calloc(mp->nmats, sizeof(OBJREC)); |
| 294 |
|
if (mp->pseudo == NULL) |
| 295 |
|
error(SYSTEM, "out of memory in getmeshpseudo"); |
| 304 |
|
|
| 305 |
|
|
| 306 |
|
int |
| 307 |
< |
getmeshtri(tv, mo, mp, ti, wha) /* get triangle vertices */ |
| 308 |
< |
MESHVERT tv[3]; |
| 309 |
< |
OBJECT *mo; |
| 310 |
< |
MESH *mp; |
| 311 |
< |
OBJECT ti; |
| 312 |
< |
int wha; |
| 307 |
> |
getmeshtri( /* get triangle vertices */ |
| 308 |
> |
MESHVERT tv[3], |
| 309 |
> |
OBJECT *mo, |
| 310 |
> |
MESH *mp, |
| 311 |
> |
OBJECT ti, |
| 312 |
> |
int wha |
| 313 |
> |
) |
| 314 |
|
{ |
| 315 |
|
int32 tvid[3]; |
| 316 |
|
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
int32 |
| 329 |
< |
addmeshvert(mp, vp) /* find/add a mesh vertex */ |
| 330 |
< |
register MESH *mp; |
| 331 |
< |
MESHVERT *vp; |
| 329 |
> |
addmeshvert( /* find/add a mesh vertex */ |
| 330 |
> |
MESH *mp, |
| 331 |
> |
MESHVERT *vp |
| 332 |
> |
) |
| 333 |
|
{ |
| 334 |
|
LUENT *lvp; |
| 335 |
|
MCVERT cv; |
| 336 |
< |
register int i; |
| 336 |
> |
int i; |
| 337 |
|
|
| 338 |
|
if (!(vp->fl & MT_V)) |
| 339 |
|
return(-1); |
| 376 |
|
memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT)); |
| 377 |
|
} |
| 378 |
|
if (lvp->data == NULL) { /* new vertex */ |
| 379 |
< |
register MESHPATCH *pp; |
| 379 |
> |
MESHPATCH *pp; |
| 380 |
|
if (mp->npatches <= 0) { |
| 381 |
|
mp->patch = (MESHPATCH *)calloc(MPATCHBLKSIZ, |
| 382 |
|
sizeof(MESHPATCH)); |
| 433 |
|
|
| 434 |
|
|
| 435 |
|
OBJECT |
| 436 |
< |
addmeshtri(mp, tv, mo) /* add a new mesh triangle */ |
| 437 |
< |
MESH *mp; |
| 438 |
< |
MESHVERT tv[3]; |
| 439 |
< |
OBJECT mo; |
| 436 |
> |
addmeshtri( /* add a new mesh triangle */ |
| 437 |
> |
MESH *mp, |
| 438 |
> |
MESHVERT tv[3], |
| 439 |
> |
OBJECT mo |
| 440 |
> |
) |
| 441 |
|
{ |
| 442 |
|
int32 vid[3], t; |
| 443 |
|
int pn[3], i; |
| 444 |
< |
register MESHPATCH *pp; |
| 444 |
> |
MESHPATCH *pp; |
| 445 |
|
|
| 446 |
|
if (!(tv[0].fl & tv[1].fl & tv[2].fl & MT_V)) |
| 447 |
|
return(OVOID); |
| 531 |
|
|
| 532 |
|
|
| 533 |
|
char * |
| 534 |
< |
checkmesh(mp) /* validate mesh data */ |
| 496 |
< |
register MESH *mp; |
| 534 |
> |
checkmesh(MESH *mp) /* validate mesh data */ |
| 535 |
|
{ |
| 536 |
|
static char embuf[128]; |
| 537 |
|
int nouvbounds = 1; |
| 538 |
< |
register int i; |
| 538 |
> |
int i; |
| 539 |
|
/* basic checks */ |
| 540 |
|
if (mp == NULL) |
| 541 |
|
return("NULL mesh pointer"); |
| 575 |
|
if (mp->npatches <= 0) |
| 576 |
|
error(WARNING, "no patches in mesh"); |
| 577 |
|
for (i = 0; i < mp->npatches; i++) { |
| 578 |
< |
register MESHPATCH *pp = &mp->patch[i]; |
| 578 |
> |
MESHPATCH *pp = &mp->patch[i]; |
| 579 |
|
if (pp->nverts <= 0) |
| 580 |
|
error(WARNING, "no vertices in patch"); |
| 581 |
|
else { |
| 597 |
|
|
| 598 |
|
|
| 599 |
|
static void |
| 600 |
< |
tallyoctree(ot, ecp, lcp, ocp) /* tally octree size */ |
| 601 |
< |
OCTREE ot; |
| 602 |
< |
int *ecp, *lcp, *ocp; |
| 600 |
> |
tallyoctree( /* tally octree size */ |
| 601 |
> |
OCTREE ot, |
| 602 |
> |
int *ecp, |
| 603 |
> |
int *lcp, |
| 604 |
> |
int *ocp |
| 605 |
> |
) |
| 606 |
|
{ |
| 607 |
|
int i; |
| 608 |
|
|
| 623 |
|
|
| 624 |
|
|
| 625 |
|
void |
| 626 |
< |
printmeshstats(ms, fp) /* print out mesh statistics */ |
| 627 |
< |
MESH *ms; |
| 628 |
< |
FILE *fp; |
| 626 |
> |
printmeshstats( /* print out mesh statistics */ |
| 627 |
> |
MESH *ms, |
| 628 |
> |
FILE *fp |
| 629 |
> |
) |
| 630 |
|
{ |
| 631 |
|
int lfcnt=0, lecnt=0, locnt=0; |
| 632 |
|
int vcnt=0, ncnt=0, uvcnt=0; |
| 636 |
|
|
| 637 |
|
tallyoctree(ms->mcube.cutree, &lecnt, &lfcnt, &locnt); |
| 638 |
|
for (i = 0; i < ms->npatches; i++) { |
| 639 |
< |
register MESHPATCH *pp = &ms->patch[i]; |
| 639 |
> |
MESHPATCH *pp = &ms->patch[i]; |
| 640 |
|
vcnt += pp->nverts; |
| 641 |
|
if (pp->norm != NULL) { |
| 642 |
|
for (j = pp->nverts; j--; ) |
| 655 |
|
t2cnt += pp->nj2tris; |
| 656 |
|
} |
| 657 |
|
fprintf(fp, "Mesh statistics:\n"); |
| 658 |
< |
fprintf(fp, "\t%ld materials\n", ms->nmats); |
| 658 |
> |
fprintf(fp, "\t%ld materials\n", (long)ms->nmats); |
| 659 |
|
fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches, |
| 660 |
|
(ms->npatches*sizeof(MESHPATCH) + |
| 661 |
|
vcnt*3*sizeof(uint32) + |
| 678 |
|
|
| 679 |
|
|
| 680 |
|
void |
| 681 |
< |
freemesh(ms) /* free mesh data */ |
| 640 |
< |
register MESH *ms; |
| 681 |
> |
freemesh(MESH *ms) /* free mesh data */ |
| 682 |
|
{ |
| 683 |
|
MESH mhead; |
| 684 |
|
MESH *msp; |
| 706 |
|
octfree(ms->mcube.cutree); |
| 707 |
|
lu_done(&ms->lut); |
| 708 |
|
if (ms->npatches > 0) { |
| 709 |
< |
register MESHPATCH *pp = ms->patch + ms->npatches; |
| 709 |
> |
MESHPATCH *pp = ms->patch + ms->npatches; |
| 710 |
|
while (pp-- > ms->patch) { |
| 711 |
|
if (pp->j2tri != NULL) |
| 712 |
|
free((void *)pp->j2tri); |
| 730 |
|
|
| 731 |
|
|
| 732 |
|
void |
| 733 |
< |
freemeshinst(o) /* free mesh instance */ |
| 693 |
< |
OBJREC *o; |
| 733 |
> |
freemeshinst(OBJREC *o) /* free mesh instance */ |
| 734 |
|
{ |
| 735 |
|
if (o->os == NULL) |
| 736 |
|
return; |