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