| 1 |
gregl |
3.1 |
/* Copyright (c) 1997 Silicon Graphics, Inc. */
|
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ SGI" */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
|
|
* Quadtree data structures for holodeck display drivers.
|
| 7 |
|
|
*/
|
| 8 |
|
|
|
| 9 |
|
|
#include "tonemap.h"
|
| 10 |
|
|
#include "rhdriver.h"
|
| 11 |
gregl |
3.7 |
|
| 12 |
|
|
#ifndef int2
|
| 13 |
|
|
#define int2 short
|
| 14 |
|
|
#endif
|
| 15 |
|
|
#ifndef int4
|
| 16 |
gregl |
3.8 |
#define int4 int
|
| 17 |
gregl |
3.7 |
#endif
|
| 18 |
gregl |
3.1 |
/* child ordering */
|
| 19 |
|
|
#define DL 0 /* down left */
|
| 20 |
|
|
#define DR 1 /* down right */
|
| 21 |
|
|
#define UL 2 /* up left */
|
| 22 |
|
|
#define UR 3 /* up right */
|
| 23 |
|
|
|
| 24 |
gregl |
3.3 |
#define BRF(i) (0x1<<(i)) /* branch flag bit */
|
| 25 |
|
|
#define LFF(i) (0x10<<(i)) /* leaf flag bit */
|
| 26 |
|
|
#define CHF(i) (0x100<<(i)) /* change flag bit */
|
| 27 |
|
|
#define CHBRF(i) (0x101<<(i)) /* changed branch bit */
|
| 28 |
|
|
#define CHLFF(i) (0x110<<(i)) /* changed leaf bit */
|
| 29 |
|
|
#define BR_ANY 0xf /* flags for any branches */
|
| 30 |
|
|
#define LF_ANY 0xf0 /* flags for any leaves */
|
| 31 |
|
|
#define CH_ANY 0xf00 /* flags for any change */
|
| 32 |
gregl |
3.1 |
|
| 33 |
|
|
typedef struct rtree {
|
| 34 |
gregl |
3.3 |
short flgs; /* content flags (defined above) */
|
| 35 |
gregl |
3.1 |
union {
|
| 36 |
|
|
struct rtree *b; /* if branch */
|
| 37 |
gregl |
3.3 |
int li; /* if leaf */
|
| 38 |
gregl |
3.1 |
} k[4]; /* children */
|
| 39 |
|
|
} RTREE;
|
| 40 |
|
|
|
| 41 |
gregl |
3.3 |
extern struct rleaves {
|
| 42 |
|
|
float (*wp)[3]; /* world intersection point array */
|
| 43 |
gregl |
3.7 |
int4 *wd; /* world direction array */
|
| 44 |
gregl |
3.3 |
TMbright *brt; /* encoded brightness array */
|
| 45 |
|
|
BYTE (*chr)[3]; /* encoded chrominance array */
|
| 46 |
|
|
BYTE (*rgb)[3]; /* tone-mapped color array */
|
| 47 |
|
|
int nl; /* count of leaves in our pile */
|
| 48 |
|
|
int bl, tl; /* bottom and top (next) leaf index */
|
| 49 |
|
|
int tml; /* next leaf needing tone-mapping */
|
| 50 |
|
|
char *base; /* base of allocated memory */
|
| 51 |
|
|
} qtL; /* our pile of leaves */
|
| 52 |
|
|
|
| 53 |
gregl |
3.5 |
#define is_stump(t) (!((t)->flgs & (BR_ANY|LF_ANY)))
|
| 54 |
|
|
|
| 55 |
gregl |
3.1 |
extern RTREE qtrunk; /* trunk of quadtree */
|
| 56 |
|
|
extern double qtDepthEps; /* epsilon to compare depths (z fraction) */
|
| 57 |
|
|
extern int qtMinNodesiz; /* minimum node dimension (pixels) */
|
| 58 |
gregl |
3.8 |
|
| 59 |
gregl |
3.9 |
extern int rayqleft; /* number of rays to queue before flush */
|
| 60 |
|
|
|
| 61 |
gregl |
3.8 |
extern int4 encodedir();
|
| 62 |
|
|
extern double fdir2diff(), dir2diff();
|