| 7 |
|
* 7/29/85 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
– |
#include "standard.h" |
| 10 |
|
#include "platform.h" |
| 11 |
+ |
#include "standard.h" |
| 12 |
|
#include "octree.h" |
| 13 |
|
#include "object.h" |
| 14 |
|
#include "otypes.h" |
| 15 |
|
#include "paths.h" |
| 16 |
+ |
#include "resolu.h" |
| 17 |
+ |
#include "oconv.h" |
| 18 |
|
|
| 19 |
|
#define OMARGIN (10*FTINY) /* margin around global cube */ |
| 20 |
|
|
| 21 |
< |
#define MAXOBJFIL 127 /* maximum number of scene files */ |
| 21 |
> |
#define MAXOBJFIL 255 /* maximum number of scene files */ |
| 22 |
|
|
| 23 |
|
char *progname; /* argv[0] */ |
| 24 |
|
|
| 28 |
|
|
| 29 |
|
int resolu = 16384; /* octree resolution limit */ |
| 30 |
|
|
| 31 |
< |
CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ |
| 31 |
> |
CUBE thescene = {{0.0, 0.0, 0.0}, 0.0, EMPTY}; /* our scene */ |
| 32 |
|
|
| 33 |
|
char *ofname[MAXOBJFIL+1]; /* object file names */ |
| 34 |
|
int nfiles = 0; /* number of object files */ |
| 37 |
|
|
| 38 |
|
void (*addobjnotify[])() = {NULL}; /* new object notifier functions */ |
| 39 |
|
|
| 40 |
+ |
static void addobject(CUBE *cu, OBJECT obj); |
| 41 |
+ |
static void add2full(CUBE *cu, OBJECT obj, int inc); |
| 42 |
|
|
| 43 |
< |
main(argc, argv) /* convert object files to an octree */ |
| 44 |
< |
int argc; |
| 45 |
< |
char *argv[]; |
| 43 |
> |
|
| 44 |
> |
int |
| 45 |
> |
main( /* convert object files to an octree */ |
| 46 |
> |
int argc, |
| 47 |
> |
char *argv[] |
| 48 |
> |
) |
| 49 |
|
{ |
| 50 |
|
FVECT bbmin, bbmax; |
| 51 |
|
char *infile = NULL; |
| 56 |
|
|
| 57 |
|
progname = argv[0] = fixargv0(argv[0]); |
| 58 |
|
|
| 59 |
< |
initotypes(); |
| 59 |
> |
ot_initotypes(); |
| 60 |
|
|
| 61 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 62 |
|
switch (argv[i][1]) { |
| 156 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
| 157 |
|
|
| 158 |
|
quit(0); |
| 159 |
+ |
return 0; /* pro forma return */ |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
|
| 163 |
|
void |
| 164 |
< |
quit(code) /* exit program */ |
| 165 |
< |
int code; |
| 164 |
> |
quit( /* exit program */ |
| 165 |
> |
int code |
| 166 |
> |
) |
| 167 |
|
{ |
| 168 |
|
exit(code); |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
void |
| 173 |
< |
cputs() /* interactive error */ |
| 173 |
> |
cputs(void) /* interactive error */ |
| 174 |
|
{ |
| 175 |
|
/* referenced, but not used */ |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
void |
| 180 |
< |
wputs(s) /* warning message */ |
| 181 |
< |
char *s; |
| 180 |
> |
wputs( /* warning message */ |
| 181 |
> |
const char *s |
| 182 |
> |
) |
| 183 |
|
{ |
| 184 |
|
if (!nowarn) |
| 185 |
|
eputs(s); |
| 187 |
|
|
| 188 |
|
|
| 189 |
|
void |
| 190 |
< |
eputs(s) /* put string to stderr */ |
| 191 |
< |
register char *s; |
| 190 |
> |
eputs( /* put string to stderr */ |
| 191 |
> |
const char *s |
| 192 |
> |
) |
| 193 |
|
{ |
| 194 |
|
static int inln = 0; |
| 195 |
|
|
| 202 |
|
inln = 0; |
| 203 |
|
} |
| 204 |
|
|
| 205 |
+ |
/* conflicting def's in param.h */ |
| 206 |
+ |
#undef tstbit |
| 207 |
+ |
#undef setbit |
| 208 |
+ |
#undef clrbit |
| 209 |
+ |
#undef tglbit |
| 210 |
|
|
| 211 |
|
#define bitop(f,i,op) (f[((i)>>3)] op (1<<((i)&7))) |
| 212 |
|
#define tstbit(f,i) bitop(f,i,&) |
| 215 |
|
#define tglbit(f,i) bitop(f,i,^=) |
| 216 |
|
|
| 217 |
|
|
| 218 |
< |
addobject(cu, obj) /* add an object to a cube */ |
| 219 |
< |
register CUBE *cu; |
| 220 |
< |
OBJECT obj; |
| 218 |
> |
static void |
| 219 |
> |
addobject( /* add an object to a cube */ |
| 220 |
> |
CUBE *cu, |
| 221 |
> |
OBJECT obj |
| 222 |
> |
) |
| 223 |
|
{ |
| 224 |
|
int inc; |
| 225 |
|
|
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
< |
add2full(cu, obj, inc) /* add object to full node */ |
| 259 |
< |
register CUBE *cu; |
| 260 |
< |
OBJECT obj; |
| 261 |
< |
int inc; |
| 258 |
> |
static void |
| 259 |
> |
add2full( /* add object to full node */ |
| 260 |
> |
CUBE *cu, |
| 261 |
> |
OBJECT obj, |
| 262 |
> |
int inc |
| 263 |
> |
) |
| 264 |
|
{ |
| 265 |
|
OCTREE ot; |
| 266 |
|
OBJECT oset[MAXSET+1]; |
| 267 |
|
CUBE cukid; |
| 268 |
|
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
| 269 |
< |
register int i, j; |
| 269 |
> |
int i, j; |
| 270 |
|
|
| 271 |
|
objset(oset, cu->cutree); |
| 272 |
|
cukid.cusize = cu->cusize * 0.5; |
| 273 |
|
|
| 274 |
< |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 274 |
> |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < |
| 275 |
> |
(oset[0] < MAXSET ? mincusize : mincusize/256.0)) { |
| 276 |
|
/* add to set */ |
| 277 |
|
if (oset[0] >= MAXSET) { |
| 278 |
|
sprintf(errmsg, "set overflow in addobject (%s)", |