| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
< |
#include "standard.h" |
| 10 |
> |
#include "rtmath.h" |
| 11 |
> |
#include "rterror.h" |
| 12 |
> |
#include "rtio.h" |
| 13 |
> |
#include "paths.h" |
| 14 |
|
|
| 15 |
|
#include "octree.h" |
| 13 |
– |
|
| 16 |
|
#include "object.h" |
| 15 |
– |
|
| 17 |
|
#include "instance.h" |
| 18 |
|
|
| 19 |
|
#define IO_ILLEGAL (IO_FILES|IO_INFO) |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
SCENE * |
| 25 |
< |
getscene(sname, flags) /* load octree sname */ |
| 25 |
> |
getscene(sname, flags) /* get new octree reference */ |
| 26 |
|
char *sname; |
| 27 |
|
int flags; |
| 28 |
|
{ |
| 31 |
|
|
| 32 |
|
flags &= ~IO_ILLEGAL; /* not allowed */ |
| 33 |
|
for (sc = slist; sc != NULL; sc = sc->next) |
| 34 |
< |
if (!strcmp(sname, sc->name)) { |
| 35 |
< |
if ((sc->ldflags & flags) == flags) { |
| 35 |
< |
sc->nref++; |
| 36 |
< |
return(sc); /* loaded */ |
| 37 |
< |
} |
| 38 |
< |
break; /* load the rest */ |
| 39 |
< |
} |
| 34 |
> |
if (!strcmp(sname, sc->name)) |
| 35 |
> |
break; |
| 36 |
|
if (sc == NULL) { |
| 37 |
|
sc = (SCENE *)malloc(sizeof(SCENE)); |
| 38 |
|
if (sc == NULL) |
| 39 |
|
error(SYSTEM, "out of memory in getscene"); |
| 40 |
|
sc->name = savestr(sname); |
| 41 |
< |
sc->nref = 1; |
| 41 |
> |
sc->nref = 0; |
| 42 |
|
sc->ldflags = 0; |
| 43 |
|
sc->scube.cutree = EMPTY; |
| 44 |
|
sc->scube.cuorg[0] = sc->scube.cuorg[1] = |
| 55 |
|
flags &= ~sc->ldflags; /* skip what's already loaded */ |
| 56 |
|
if (flags & IO_SCENE) |
| 57 |
|
sc->firstobj = nobjects; |
| 58 |
< |
readoct(pathname, flags, &sc->scube, NULL); |
| 58 |
> |
if (flags) |
| 59 |
> |
readoct(pathname, flags, &sc->scube, NULL); |
| 60 |
|
if (flags & IO_SCENE) |
| 61 |
|
sc->nobjs = nobjects - sc->firstobj; |
| 62 |
|
sc->ldflags |= flags; |
| 63 |
+ |
sc->nref++; /* increase reference count */ |
| 64 |
|
return(sc); |
| 65 |
|
} |
| 66 |
|
|
| 88 |
|
ins->obj = NULL; |
| 89 |
|
o->os = (char *)ins; |
| 90 |
|
} |
| 91 |
< |
if (ins->obj == NULL || (ins->obj->ldflags & flags) != flags) |
| 91 |
> |
if (ins->obj == NULL) |
| 92 |
|
ins->obj = getscene(o->oargs.sarg[0], flags); |
| 93 |
+ |
else if ((flags &= ~ins->obj->ldflags)) { |
| 94 |
+ |
if (flags & IO_SCENE) |
| 95 |
+ |
ins->obj->firstobj = nobjects; |
| 96 |
+ |
if (flags) |
| 97 |
+ |
readoct(getpath(o->oargs.sarg[0], getrlibpath(), R_OK), |
| 98 |
+ |
flags, &ins->obj->scube, NULL); |
| 99 |
+ |
if (flags & IO_SCENE) |
| 100 |
+ |
ins->obj->nobjs = nobjects - ins->obj->firstobj; |
| 101 |
+ |
ins->obj->ldflags |= flags; |
| 102 |
+ |
} |
| 103 |
|
return(ins); |
| 104 |
|
} |
| 105 |
|
|