Back to index

radiance  4R0+20100331
rhd_qtree.h
Go to the documentation of this file.
00001 /* RCSid $Id: rhd_qtree.h,v 3.18 2005/01/07 20:33:02 greg Exp $ */
00002 /*
00003  * Quadtree data structures for holodeck display drivers.
00004  */
00005 #ifndef _RAD_RHD_QTREE_H_
00006 #define _RAD_RHD_QTREE_H_
00007 
00008 #include "color.h"
00009 #include "tonemap.h"
00010 #include "rhdriver.h"
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016 #define       DL            0             /* down left */
00017 #define       DR            1             /* down right */
00018 #define       UL            2             /* up left */
00019 #define       UR            3             /* up right */
00020 
00021 #define       BRF(i)        (0x1<<(i))    /* branch flag bit */
00022 #define LFF(i)              (0x10<<(i))   /* leaf flag bit */
00023 #define CHF(i)              (0x100<<(i))  /* change flag bit */
00024 #define       CHBRF(i)      (0x101<<(i))  /* changed branch bit */
00025 #define CHLFF(i)     (0x110<<(i))  /* changed leaf bit */
00026 #define BR_ANY              0xf           /* flags for any branches */
00027 #define LF_ANY              0xf0          /* flags for any leaves */
00028 #define CH_ANY              0xf00         /* flags for any change */
00029 
00030 typedef struct rtree {
00031        short  flgs;                /* content flags (defined above) */
00032        union {
00033               struct rtree  *b;           /* if branch */
00034               int    li;                  /* if leaf */
00035        } k[4];                            /* children */
00036 }      RTREE;
00037 
00038 extern struct rleaves {
00039        float         (*wp)[3];     /* world intersection point array */
00040        int32         *wd;          /* world direction array */
00041        TMbright      *brt;         /* encoded brightness array */
00042        BYTE          (*chr)[3];    /* encoded chrominance array */
00043        BYTE          (*rgb)[3];    /* tone-mapped color array */
00044        int           nl;           /* count of leaves in our pile */
00045        int           bl, tl;              /* bottom and top (next) leaf index */
00046        int           tml;          /* next leaf needing tone-mapping */
00047        char          *base;        /* base of allocated memory */
00048 }      qtL;                 /* our pile of leaves */
00049 
00050 #define       is_stump(t)   (!((t)->flgs & (BR_ANY|LF_ANY)))
00051 
00052 extern RTREE  qtrunk;              /* trunk of quadtree */
00053 extern double qtDepthEps;   /* epsilon to compare depths (z fraction) */
00054 extern int    qtMinNodesiz; /* minimum node dimension (pixels) */
00055 
00056 extern int    rayqleft;     /* number of rays to queue before flush */
00057 
00058 extern TMstruct      *tmGlobal;    /* global tone-mapping structure */
00059 
00060 /*
00061 extern int32  encodedir();
00062 extern double fdir2diff(), dir2diff();
00063 */
00064 
00065        /* rhd_qtree.c */
00066 extern int qtAllocLeaves(register int n);
00067 extern void qtFreeLeaves(void);
00068 extern int qtCompost(int pct);
00069 extern void qtReplant(void);
00070 extern int qtFindLeaf(int x, int y);
00071 extern int qtMapLeaves(int redo);
00072        /* rhd_qtree2c.c rhd_qtree2r.c */
00073 extern void qtRedraw(int x0, int y0, int x1, int y1);
00074 extern void qtUpdate(void);
00075 
00076 #ifdef __cplusplus
00077 }
00078 #endif
00079 #endif /* _RAD_RHD_QTREE_H_ */
00080