79 |
|
|
80 |
|
flags &= IO_LEGAL; |
81 |
|
for (ms = mlist; ms != NULL; ms = ms->next) |
82 |
< |
if (!strcmp(mname, ms->name)) |
82 |
> |
if (!strcmp(mname, ms->name)) { |
83 |
> |
ms->nref++; /* increase reference count */ |
84 |
|
break; |
85 |
+ |
} |
86 |
|
if (ms == NULL) { /* load first time */ |
87 |
|
ms = (MESH *)calloc(1, sizeof(MESH)); |
88 |
|
if (ms == NULL) |
89 |
|
error(SYSTEM, "out of memory in getmesh"); |
90 |
|
ms->name = savestr(mname); |
91 |
+ |
ms->nref = 1; |
92 |
|
ms->mcube.cutree = EMPTY; |
93 |
|
ms->next = mlist; |
94 |
|
mlist = ms; |
100 |
|
flags &= ~ms->ldflags; |
101 |
|
if (flags) |
102 |
|
readmesh(ms, pathname, flags); |
100 |
– |
ms->nref++; /* increase reference count */ |
103 |
|
return(ms); |
104 |
|
} |
105 |
|
|
410 |
|
pn[i] = vid[i] >> 8; |
411 |
|
} |
412 |
|
/* normalize material index */ |
413 |
< |
if (mo != OVOID) |
413 |
> |
if (mo != OVOID) { |
414 |
|
if ((mo -= mp->mat0) >= mp->nmats) |
415 |
|
mp->nmats = mo+1; |
416 |
|
else if (mo < 0) |
417 |
|
error(INTERNAL, "modifier range error in addmeshtri"); |
418 |
+ |
} |
419 |
|
/* assign triangle */ |
420 |
|
if (pn[0] == pn[1] && pn[1] == pn[2]) { /* local case */ |
421 |
|
pp = &mp->patch[pn[0]]; |
612 |
|
t2cnt += pp->nj2tris; |
613 |
|
} |
614 |
|
fprintf(fp, "Mesh statistics:\n"); |
615 |
< |
fprintf(fp, "\t%d materials\n", ms->nmats); |
615 |
> |
fprintf(fp, "\t%ld materials\n", ms->nmats); |
616 |
|
fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches, |
617 |
|
(ms->npatches*sizeof(MESHPATCH) + |
618 |
|
vcnt*3*sizeof(uint32) + |