1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ SGI" */ |
4 |
< |
|
1 |
> |
/* RCSid $Id$ */ |
2 |
|
/* |
3 |
|
* Quadtree data structures for holodeck display drivers. |
4 |
|
*/ |
5 |
+ |
#ifndef _RAD_RHD_QTREE_H_ |
6 |
+ |
#define _RAD_RHD_QTREE_H_ |
7 |
|
|
8 |
+ |
#include "color.h" |
9 |
|
#include "tonemap.h" |
10 |
|
#include "rhdriver.h" |
11 |
< |
/* quantity of leaves to free at a time */ |
12 |
< |
#ifndef LFREEPCT |
13 |
< |
#define LFREEPCT 15 |
11 |
> |
|
12 |
> |
#ifdef __cplusplus |
13 |
> |
extern "C" { |
14 |
|
#endif |
15 |
< |
/* child ordering */ |
15 |
> |
|
16 |
|
#define DL 0 /* down left */ |
17 |
|
#define DR 1 /* down right */ |
18 |
|
#define UL 2 /* up left */ |
19 |
|
#define UR 3 /* up right */ |
20 |
|
|
21 |
< |
#define BRF(i) (1<<(i)) /* branch flag bit */ |
22 |
< |
#define CHF(i) (0x10<<(i)) /* change flag bit */ |
23 |
< |
#define CHBRF(i) (0x11<<(i)) /* changed branch flags */ |
24 |
< |
#define CH_ANY 0xf0 /* flags for any change */ |
21 |
> |
#define BRF(i) (0x1<<(i)) /* branch flag bit */ |
22 |
> |
#define LFF(i) (0x10<<(i)) /* leaf flag bit */ |
23 |
> |
#define CHF(i) (0x100<<(i)) /* change flag bit */ |
24 |
> |
#define CHBRF(i) (0x101<<(i)) /* changed branch bit */ |
25 |
> |
#define CHLFF(i) (0x110<<(i)) /* changed leaf bit */ |
26 |
> |
#define BR_ANY 0xf /* flags for any branches */ |
27 |
> |
#define LF_ANY 0xf0 /* flags for any leaves */ |
28 |
> |
#define CH_ANY 0xf00 /* flags for any change */ |
29 |
|
|
26 |
– |
typedef struct { |
27 |
– |
float wp[3]; /* world intersection point */ |
28 |
– |
TMbright brt; /* encoded brightness (LogY) */ |
29 |
– |
BYTE chr[3]; /* encoded chrominance (RGB) */ |
30 |
– |
} RLEAF; /* recorded ray (leaf) value */ |
31 |
– |
|
30 |
|
typedef struct rtree { |
31 |
< |
short flgs; /* branch flags */ |
31 |
> |
short flgs; /* content flags (defined above) */ |
32 |
|
union { |
33 |
|
struct rtree *b; /* if branch */ |
34 |
< |
RLEAF *l; /* if leaf */ |
34 |
> |
int li; /* if leaf */ |
35 |
|
} k[4]; /* children */ |
36 |
|
} RTREE; |
37 |
|
|
38 |
+ |
extern struct rleaves { |
39 |
+ |
float (*wp)[3]; /* world intersection point array */ |
40 |
+ |
int32 *wd; /* world direction array */ |
41 |
+ |
TMbright *brt; /* encoded brightness array */ |
42 |
+ |
uby8 (*chr)[3]; /* encoded chrominance array */ |
43 |
+ |
uby8 (*rgb)[3]; /* tone-mapped color array */ |
44 |
+ |
int nl; /* count of leaves in our pile */ |
45 |
+ |
int bl, tl; /* bottom and top (next) leaf index */ |
46 |
+ |
int tml; /* next leaf needing tone-mapping */ |
47 |
+ |
char *base; /* base of allocated memory */ |
48 |
+ |
} qtL; /* our pile of leaves */ |
49 |
+ |
|
50 |
+ |
#define is_stump(t) (!((t)->flgs & (BR_ANY|LF_ANY))) |
51 |
+ |
|
52 |
|
extern RTREE qtrunk; /* trunk of quadtree */ |
53 |
|
extern double qtDepthEps; /* epsilon to compare depths (z fraction) */ |
54 |
|
extern int qtMinNodesiz; /* minimum node dimension (pixels) */ |
55 |
|
|
56 |
+ |
extern int rayqleft; /* number of rays to queue before flush */ |
57 |
|
|
58 |
< |
/************************************************************************ |
46 |
< |
* These driver support routines implement the dev_value() call, but |
47 |
< |
* require the following callbacks: |
58 |
> |
extern TMstruct *tmGlobal; /* global tone-mapping structure */ |
59 |
|
|
60 |
< |
dev_paintr(rgb, x0, y0, x1, y1) : paint a rectangle |
61 |
< |
BYTE rgb[3]; : rectangle color |
62 |
< |
int x0, y0, x1, y1; : rectangle boundaries |
60 |
> |
/* rhd_qtree.c */ |
61 |
> |
extern int qtAllocLeaves(register int n); |
62 |
> |
extern void qtFreeLeaves(void); |
63 |
> |
extern int qtCompost(int pct); |
64 |
> |
extern void qtReplant(void); |
65 |
> |
extern int qtFindLeaf(int x, int y); |
66 |
> |
extern int qtMapLeaves(int redo); |
67 |
> |
/* rhd_qtree2c.c rhd_qtree2r.c */ |
68 |
> |
extern void qtRedraw(int x0, int y0, int x1, int y1); |
69 |
> |
extern void qtUpdate(void); |
70 |
|
|
71 |
< |
Draws an open rectangle between [x0,x1) and [y0,y1) with the color rgb. |
72 |
< |
This function is called many times by qtUpdate(), qtRedraw() and qtReplant(). |
71 |
> |
#ifdef __cplusplus |
72 |
> |
} |
73 |
> |
#endif |
74 |
> |
#endif /* _RAD_RHD_QTREE_H_ */ |
75 |
|
|
56 |
– |
************************************************************************/ |