| 5 |
|
* Mesh support routines |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include <string.h> |
| 9 |
+ |
|
| 10 |
|
#include "standard.h" |
| 11 |
|
#include "octree.h" |
| 12 |
|
#include "object.h" |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
MESH * |
| 73 |
< |
getmesh(mname, flags) /* get mesh data */ |
| 73 |
> |
getmesh(mname, flags) /* get new mesh data reference */ |
| 74 |
|
char *mname; |
| 75 |
|
int flags; |
| 76 |
|
{ |
| 79 |
|
|
| 80 |
|
flags &= IO_LEGAL; |
| 81 |
|
for (ms = mlist; ms != NULL; ms = ms->next) |
| 82 |
< |
if (!strcmp(mname, ms->name)) { |
| 83 |
< |
if ((ms->ldflags & flags) == flags) { |
| 84 |
< |
ms->nref++; |
| 83 |
< |
return(ms); /* loaded */ |
| 84 |
< |
} |
| 85 |
< |
break; /* load the rest */ |
| 86 |
< |
} |
| 87 |
< |
if (ms == NULL) { |
| 82 |
> |
if (!strcmp(mname, ms->name)) |
| 83 |
> |
break; |
| 84 |
> |
if (ms == NULL) { /* load first time */ |
| 85 |
|
ms = (MESH *)calloc(1, sizeof(MESH)); |
| 86 |
|
if (ms == NULL) |
| 87 |
|
error(SYSTEM, "out of memory in getmesh"); |
| 88 |
|
ms->name = savestr(mname); |
| 92 |
– |
ms->nref = 1; |
| 89 |
|
ms->mcube.cutree = EMPTY; |
| 90 |
|
ms->next = mlist; |
| 91 |
|
mlist = ms; |
| 97 |
|
flags &= ~ms->ldflags; |
| 98 |
|
if (flags) |
| 99 |
|
readmesh(ms, pathname, flags); |
| 100 |
+ |
ms->nref++; /* increase reference count */ |
| 101 |
|
return(ms); |
| 102 |
|
} |
| 103 |
|
|
| 125 |
|
ins->msh = NULL; |
| 126 |
|
o->os = (char *)ins; |
| 127 |
|
} |
| 128 |
< |
if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags) |
| 128 |
> |
if (ins->msh == NULL) |
| 129 |
|
ins->msh = getmesh(o->oargs.sarg[0], flags); |
| 130 |
+ |
else if ((flags &= ~ins->msh->ldflags)) |
| 131 |
+ |
readmesh(ins->msh, |
| 132 |
+ |
getpath(o->oargs.sarg[0], getrlibpath(), R_OK), |
| 133 |
+ |
flags); |
| 134 |
|
return(ins); |
| 135 |
|
} |
| 136 |
|
|
| 330 |
|
goto nomem; |
| 331 |
|
if (lvp->key == NULL) { |
| 332 |
|
lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32)); |
| 333 |
< |
bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT)); |
| 333 |
> |
memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT)); |
| 334 |
|
} |
| 335 |
|
if (lvp->data == NULL) { /* new vertex */ |
| 336 |
|
register MESHPATCH *pp; |
| 346 |
|
(void *)mp->patch, |
| 347 |
|
(mp->npatches + MPATCHBLKSIZ)* |
| 348 |
|
sizeof(MESHPATCH)); |
| 349 |
< |
bzero((void *)(mp->patch + mp->npatches), |
| 349 |
> |
memset((void *)(mp->patch + mp->npatches), '\0', |
| 350 |
|
MPATCHBLKSIZ*sizeof(MESHPATCH)); |
| 351 |
|
} |
| 352 |
|
if (mp->npatches++ >= 1L<<22) |