1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ LBL" */ |
4 |
< |
|
1 |
> |
/* RCSid $Id$ */ |
2 |
|
/* |
3 |
|
* octree.h - header file for routines using octrees. |
7 |
– |
* |
8 |
– |
* 7/28/85 |
4 |
|
*/ |
5 |
|
|
6 |
+ |
#include "copyright.h" |
7 |
+ |
|
8 |
|
/* |
9 |
|
* An octree is expressed as an integer which is either |
10 |
|
* an index to eight other nodes, the empty tree, or an index |
17 |
|
* < -1: it is an index to a set of objects |
18 |
|
*/ |
19 |
|
|
20 |
< |
typedef int OCTREE; |
20 |
> |
#ifndef OCTREE |
21 |
> |
#define OCTREE int |
22 |
> |
#endif |
23 |
|
|
24 |
|
#define EMPTY (-1) |
25 |
|
|
28 |
|
#define istree(ot) ((ot) > EMPTY) |
29 |
|
|
30 |
|
#define oseti(ot) (-(ot)-2) /* object set index */ |
31 |
< |
#define octbi(ot) ((ot)>>8) /* octree block index */ |
32 |
< |
#define octti(ot) (((ot)&0377)<<3)/* octree index in block */ |
31 |
> |
#define OCTBLKSIZ 04000 /* octree block size */ |
32 |
> |
#define octbi(ot) ((ot)>>11) /* octree block index */ |
33 |
> |
#define octti(ot) (((ot)&03777)<<3)/* octree index in block */ |
34 |
|
|
35 |
+ |
#ifndef MAXOBLK |
36 |
+ |
#ifdef BIGMEM |
37 |
+ |
#define MAXOBLK 32767 /* maximum octree block */ |
38 |
+ |
#else |
39 |
|
#define MAXOBLK 4095 /* maximum octree block */ |
40 |
+ |
#endif |
41 |
+ |
#endif |
42 |
|
|
43 |
|
extern OCTREE *octblock[MAXOBLK]; /* octree blocks */ |
44 |
|
|
45 |
|
#define octkid(ot,br) (octblock[octbi(ot)][octti(ot)+br]) |
46 |
|
|
41 |
– |
extern OCTREE octalloc(), combine(), fullnode(); |
42 |
– |
|
47 |
|
/* |
48 |
|
* The cube structure is used to hold an octree and its cubic |
49 |
|
* boundaries. |
68 |
|
/* octree format identifier */ |
69 |
|
#define OCTFMT "Radiance_octree" |
70 |
|
/* magic number for octree files */ |
71 |
< |
#define OCTMAGIC (283+sizeof(OBJECT)) |
71 |
> |
#define MAXOBJSIZ 8 /* maximum sizeof(OBJECT) */ |
72 |
> |
#define OCTMAGIC ( 4 *MAXOBJSIZ+251) /* increment first value */ |
73 |
|
/* octree node types */ |
74 |
|
#define OT_EMPTY 0 |
75 |
|
#define OT_FULL 1 |
78 |
|
#define O_MISS 0 /* no intersection */ |
79 |
|
#define O_HIT 1 /* intersection */ |
80 |
|
#define O_IN 2 /* cube contained entirely */ |
81 |
+ |
|
82 |
+ |
#ifdef NOPROTO |
83 |
+ |
|
84 |
+ |
extern OCTREE octalloc(); |
85 |
+ |
extern void octfree(); |
86 |
+ |
extern void octdone(); |
87 |
+ |
extern OCTREE combine(); |
88 |
+ |
extern void culocate(); |
89 |
+ |
extern void cucopy(); |
90 |
+ |
extern int incube(); |
91 |
+ |
|
92 |
+ |
extern int readoct(); |
93 |
+ |
|
94 |
+ |
#else |
95 |
+ |
|
96 |
+ |
extern OCTREE octalloc(void); |
97 |
+ |
extern void octfree(OCTREE ot); |
98 |
+ |
extern void octdone(void); |
99 |
+ |
extern OCTREE combine(OCTREE ot); |
100 |
+ |
extern void culocate(CUBE *cu, FVECT pt); |
101 |
+ |
extern void cucopy(CUBE *cu1, CUBE *cu2); |
102 |
+ |
extern int incube(CUBE *cu, FVECT pt); |
103 |
+ |
|
104 |
+ |
extern int readoct(char *fname, int load, CUBE *scene, char *ofn[]); |
105 |
+ |
|
106 |
+ |
#endif |