ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_qtree.h
Revision: 3.2
Committed: Thu Aug 20 16:47:22 1998 UTC (25 years, 8 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.1: +2 -2 lines
Log Message:
switched to barycentric coordinates
fixed background poly rendering

File Contents

# Content
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
3 /* SCCSid "$SunId$ SGI" */
4
5 /*
6 * sm_qtree.h - header file for routines using spherical quadtrees.
7 *
8 * adapted from octree.h
9 */
10
11 /*
12 * An quadtree is expressed as an integer which is either
13 * an index to 4 other nodes, the empty tree, or an index
14 * to a set of objects. If the quadtree has a value:
15 *
16 * > -1: it is an index to four other nodes.
17 *
18 * -1: it is empty
19 *
20 * < -1: it is an index to a set of objects
21 */
22
23 #define QUADTREE int
24
25 #define EMPTY (-1)
26
27 #define QT_IS_EMPTY(qt) ((qt) == EMPTY)
28 #define QT_IS_LEAF(qt) ((qt) < EMPTY)
29 #define QT_IS_TREE(qt) ((qt) > EMPTY)
30
31 #define QT_INDEX(qt) (-(qt)-2) /* quadtree node from set */
32 #define QT_SET_INDEX(i) (-((i)+2)) /* object set from node */
33 #define QT_BLOCK(qt) ((qt)>>8) /* quadtree block index */
34 #define QT_BLOCK_INDEX(qt) (((qt)&0377)<<2) /* quadtree index in block */
35
36 #ifndef QT_MAX_BLK
37 #ifdef BIGMEM
38 #define QT_MAX_BLK 65535 /* maximum quadtree block */
39 #else
40 #define QT_MAX_BLK 8191 /* maximum quadtree block */
41 #endif
42 #endif
43
44
45
46 #define QT_NTH_CHILD(qt,br) (quad_block[QT_BLOCK(qt)][QT_BLOCK_INDEX(qt)+br])
47 #define QT_NTH_CHILD_PTR(qt,br) \
48 (&(quad_block[QT_BLOCK(qt)][QT_BLOCK_INDEX(qt)+br]))
49 #define QT_CLEAR_CHILDREN(qt) (QT_NTH_CHILD(qt,0)=EMPTY, \
50 QT_NTH_CHILD(qt,1)=EMPTY,QT_NTH_CHILD(qt,2)=EMPTY,QT_NTH_CHILD(qt,3)=EMPTY)
51
52
53 #if 0
54 #define QT_EMPTY 0
55 #define QT_FULL 1
56 #define QT_TREE 2
57 #endif
58
59
60
61 /* OBJECT SET CODE */
62 #define QT_SET_CNT(s) ((s)[0])
63 #define QT_SET_NTH_ELEM(s,n) ((s)[(n)])
64
65 #define QT_CLEAR_SET(s) ((s)[0] = 0)
66 #define QT_SET_NEXT_ELEM(p) (*(p)++)
67 #define QT_SET_PTR(s) (&((s)[1]))
68
69
70 #define QT_MAX_SET MAXSET
71 #define MAXCSET MAXSET*2
72 #ifndef QT_SET_THRESHOLD
73 #define QT_SET_THRESHOLD 30
74 #endif
75
76 #ifndef QT_MAX_LEVELS
77 #define QT_MAX_LEVELS 17
78 #endif
79
80 #define QT_BLOCK_SIZE 256
81
82 extern QUADTREE qtnewleaf(), qtaddelem(), qtdelelem();
83
84 extern QUADTREE *quad_block[QT_MAX_BLK]; /* quadtree blocks */