| 7 |
|
|
| 8 |
|
#include <string.h> |
| 9 |
|
|
| 10 |
< |
#include "standard.h" |
| 10 |
> |
#include "rtio.h" |
| 11 |
> |
#include "rtmath.h" |
| 12 |
> |
#include "rterror.h" |
| 13 |
|
#include "octree.h" |
| 14 |
|
#include "object.h" |
| 15 |
|
#include "otypes.h" |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
MESH * |
| 75 |
< |
getmesh(mname, flags) /* get mesh data */ |
| 75 |
> |
getmesh(mname, flags) /* get new mesh data reference */ |
| 76 |
|
char *mname; |
| 77 |
|
int flags; |
| 78 |
|
{ |
| 82 |
|
flags &= IO_LEGAL; |
| 83 |
|
for (ms = mlist; ms != NULL; ms = ms->next) |
| 84 |
|
if (!strcmp(mname, ms->name)) { |
| 85 |
< |
if ((ms->ldflags & flags) == flags) { |
| 86 |
< |
ms->nref++; |
| 85 |
< |
return(ms); /* loaded */ |
| 86 |
< |
} |
| 87 |
< |
break; /* load the rest */ |
| 85 |
> |
ms->nref++; /* increase reference count */ |
| 86 |
> |
break; |
| 87 |
|
} |
| 88 |
< |
if (ms == NULL) { |
| 88 |
> |
if (ms == NULL) { /* load first time */ |
| 89 |
|
ms = (MESH *)calloc(1, sizeof(MESH)); |
| 90 |
|
if (ms == NULL) |
| 91 |
|
error(SYSTEM, "out of memory in getmesh"); |
| 129 |
|
ins->msh = NULL; |
| 130 |
|
o->os = (char *)ins; |
| 131 |
|
} |
| 132 |
< |
if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags) |
| 132 |
> |
if (ins->msh == NULL) |
| 133 |
|
ins->msh = getmesh(o->oargs.sarg[0], flags); |
| 134 |
+ |
else if ((flags &= ~ins->msh->ldflags)) |
| 135 |
+ |
readmesh(ins->msh, |
| 136 |
+ |
getpath(o->oargs.sarg[0], getrlibpath(), R_OK), |
| 137 |
+ |
flags); |
| 138 |
|
return(ins); |
| 139 |
|
} |
| 140 |
|
|
| 308 |
|
(vp->v[i] - mp->mcube.cuorg[i]) / |
| 309 |
|
mp->mcube.cusize); |
| 310 |
|
} |
| 311 |
< |
if (vp->fl & MT_N) |
| 311 |
> |
if (vp->fl & MT_N) /* assumes normalized! */ |
| 312 |
|
cv.norm = encodedir(vp->n); |
| 313 |
|
if (vp->fl & MT_UV) |
| 314 |
|
for (i = 0; i < 2; i++) { |
| 412 |
|
pn[i] = vid[i] >> 8; |
| 413 |
|
} |
| 414 |
|
/* normalize material index */ |
| 415 |
< |
if (mo != OVOID) |
| 415 |
> |
if (mo != OVOID) { |
| 416 |
|
if ((mo -= mp->mat0) >= mp->nmats) |
| 417 |
|
mp->nmats = mo+1; |
| 418 |
|
else if (mo < 0) |
| 419 |
|
error(INTERNAL, "modifier range error in addmeshtri"); |
| 420 |
+ |
} |
| 421 |
|
/* assign triangle */ |
| 422 |
|
if (pn[0] == pn[1] && pn[1] == pn[2]) { /* local case */ |
| 423 |
|
pp = &mp->patch[pn[0]]; |
| 614 |
|
t2cnt += pp->nj2tris; |
| 615 |
|
} |
| 616 |
|
fprintf(fp, "Mesh statistics:\n"); |
| 617 |
< |
fprintf(fp, "\t%d materials\n", ms->nmats); |
| 617 |
> |
fprintf(fp, "\t%ld materials\n", ms->nmats); |
| 618 |
|
fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches, |
| 619 |
|
(ms->npatches*sizeof(MESHPATCH) + |
| 620 |
|
vcnt*3*sizeof(uint32) + |