| 34 |
|
for (sc = slist; sc != NULL; sc = sc->next) |
| 35 |
|
if (!strcmp(sname, sc->name)) |
| 36 |
|
break; |
| 37 |
< |
if (sc == NULL) { |
| 38 |
< |
sc = (SCENE *)malloc(sizeof(SCENE)); |
| 37 |
> |
if (sc == NULL) { /* new instance? */ |
| 38 |
> |
sc = (SCENE *)calloc(1, sizeof(SCENE)); |
| 39 |
|
if (sc == NULL) |
| 40 |
|
error(SYSTEM, "out of memory in getscene"); |
| 41 |
|
sc->name = savestr(sname); |
| 42 |
– |
sc->nref = 0; |
| 43 |
– |
sc->ldflags = 0; |
| 42 |
|
sc->scube.cutree = EMPTY; |
| 45 |
– |
sc->scube.cuorg[0] = sc->scube.cuorg[1] = |
| 46 |
– |
sc->scube.cuorg[2] = 0.; |
| 47 |
– |
sc->scube.cusize = 0.; |
| 48 |
– |
sc->firstobj = sc->nobjs = 0; |
| 43 |
|
sc->next = slist; |
| 44 |
|
slist = sc; |
| 45 |
|
} |
| 46 |
+ |
sc->nref++; /* bump reference count */ |
| 47 |
+ |
if (!(flags &= ~sc->ldflags)) /* nothing to load? */ |
| 48 |
+ |
return(sc); |
| 49 |
|
if ((pathname = getpath(sname, getrlibpath(), R_OK)) == NULL) { |
| 50 |
|
sprintf(errmsg, "cannot find octree file \"%s\"", sname); |
| 51 |
|
error(SYSTEM, errmsg); |
| 52 |
|
} |
| 56 |
– |
flags &= ~sc->ldflags; /* skip what's already loaded */ |
| 53 |
|
if (flags & IO_SCENE) |
| 54 |
|
sc->firstobj = nobjects; |
| 55 |
|
if (flags) |
| 57 |
|
if (flags & IO_SCENE) |
| 58 |
|
sc->nobjs = nobjects - sc->firstobj; |
| 59 |
|
sc->ldflags |= flags; |
| 64 |
– |
sc->nref++; /* increase reference count */ |
| 60 |
|
return(sc); |
| 61 |
|
} |
| 62 |
|
|