--- ray/src/common/mesh.c 2003/06/20 00:25:49 2.8 +++ ray/src/common/mesh.c 2003/07/10 03:30:11 2.10 @@ -1,10 +1,12 @@ #ifndef lint -static const char RCSid[] = "$Id: mesh.c,v 2.8 2003/06/20 00:25:49 greg Exp $"; +static const char RCSid[] = "$Id: mesh.c,v 2.10 2003/07/10 03:30:11 greg Exp $"; #endif /* * Mesh support routines */ +#include + #include "standard.h" #include "octree.h" #include "object.h" @@ -68,7 +70,7 @@ register MCVERT *v1, *v2; MESH * -getmesh(mname, flags) /* get mesh data */ +getmesh(mname, flags) /* get new mesh data reference */ char *mname; int flags; { @@ -77,19 +79,13 @@ int flags; flags &= IO_LEGAL; for (ms = mlist; ms != NULL; ms = ms->next) - if (!strcmp(mname, ms->name)) { - if ((ms->ldflags & flags) == flags) { - ms->nref++; - return(ms); /* loaded */ - } - break; /* load the rest */ - } - if (ms == NULL) { + if (!strcmp(mname, ms->name)) + break; + if (ms == NULL) { /* load first time */ ms = (MESH *)calloc(1, sizeof(MESH)); if (ms == NULL) error(SYSTEM, "out of memory in getmesh"); ms->name = savestr(mname); - ms->nref = 1; ms->mcube.cutree = EMPTY; ms->next = mlist; mlist = ms; @@ -101,6 +97,7 @@ int flags; flags &= ~ms->ldflags; if (flags) readmesh(ms, pathname, flags); + ms->nref++; /* increase reference count */ return(ms); } @@ -128,8 +125,12 @@ int flags; ins->msh = NULL; o->os = (char *)ins; } - if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags) + if (ins->msh == NULL) ins->msh = getmesh(o->oargs.sarg[0], flags); + else if ((flags &= ~ins->msh->ldflags)) + readmesh(ins->msh, + getpath(o->oargs.sarg[0], getrlibpath(), R_OK), + flags); return(ins); } @@ -329,7 +330,7 @@ MESHVERT *vp; goto nomem; if (lvp->key == NULL) { lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32)); - bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT)); + memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT)); } if (lvp->data == NULL) { /* new vertex */ register MESHPATCH *pp; @@ -345,7 +346,7 @@ MESHVERT *vp; (void *)mp->patch, (mp->npatches + MPATCHBLKSIZ)* sizeof(MESHPATCH)); - bzero((void *)(mp->patch + mp->npatches), + memset((void *)(mp->patch + mp->npatches), '\0', MPATCHBLKSIZ*sizeof(MESHPATCH)); } if (mp->npatches++ >= 1L<<22)