--- ray/src/common/mesh.c 2003/06/30 14:59:11 2.9 +++ ray/src/common/mesh.c 2003/07/10 03:47:00 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: mesh.c,v 2.9 2003/06/30 14:59:11 schorsch Exp $"; +static const char RCSid[] = "$Id: mesh.c,v 2.11 2003/07/10 03:47:00 greg Exp $"; #endif /* * Mesh support routines @@ -70,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; { @@ -80,13 +80,10 @@ 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 */ + ms->nref++; /* increase reference count */ + break; } - if (ms == NULL) { + if (ms == NULL) { /* load first time */ ms = (MESH *)calloc(1, sizeof(MESH)); if (ms == NULL) error(SYSTEM, "out of memory in getmesh"); @@ -130,8 +127,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); }