--- ray/src/hd/sm_qtree.h 1998/09/16 18:16:29 3.6 +++ ray/src/hd/sm_qtree.h 2003/08/30 08:17:32 3.17 @@ -1,13 +1,16 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - -/* SCCSid "$SunId$ SGI" */ - +/* RCSid: $Id: sm_qtree.h,v 3.17 2003/08/30 08:17:32 schorsch Exp $ */ /* * sm_qtree.h - header file for routines using spherical quadtrees. * * adapted from octree.h */ +#ifndef _RAD_SM_QTREE_H_ +#define _RAD_SM_QTREE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * An quadtree is expressed as an integer which is either * an index to 4 other nodes, the empty tree, or an index @@ -19,8 +22,16 @@ * * < -1: it is an index to a set of objects */ -#include "object.h" +typedef struct _FUNC { + int (*func)(); + int (*func_after)(); + int *argptr; +}FUNC; + +#define F_FUNC(f) (f.func) +#define F_FUNC2(f) (f.func_after) +#define F_ARGS(f) (f.argptr) #define QUADTREE int #define EMPTY (-1) @@ -37,10 +48,10 @@ #ifndef QT_MAX_BLK -#ifdef BIGMEM -#define QT_MAX_BLK 16383 /* maximum quadtree block */ -#else +#ifdef SMLMEM #define QT_MAX_BLK 2047 /* maximum quadtree block */ +#else +#define QT_MAX_BLK 16383 /* maximum quadtree block */ #endif #endif @@ -52,20 +63,19 @@ /* QUADTREE NODE FLAGS */ -#define QT_OFFSET(qt) ((qt)>>5) -#define QT_F_BIT(qt) ((qt)&0x1f) -#define QT_F_OP(f,qt,op) ((f)[QT_OFFSET(qt)] op (0x1< a?4:0) | (b1[0] > a?2:0) | (b2[0] > a?1:0)), \ + s1 = ((b0[1] > b?4:0) | (b1[1] > b?2:0) | (b2[1] > b?1:0)), \ + s2 = ((b0[2] > c?4:0) | (b1[2] > c?2:0) | (b2[2] > c?1:0))) + +#define SIDES_LESS(b0,b1,b2,s0,s1,s2,a,b,c) \ + (s0 = ((b0[0] < a?4:0) | (b1[0] < a?2:0) | (b2[0] < a?1:0)), \ + s1 = ((b0[1] < b?4:0) | (b1[1] < b?2:0) | (b2[1] < b?1:0)), \ + s2 = ((b0[2] < c?4:0) | (b1[2] < c?2:0) | (b2[2] < c?1:0))) + +/* +QUADTREE qtRoot_point_locate(qt,q0,q1,q2,peq,pt,r0,r1,r2) + QUADTREE qt; + FVECT q0,q1,q2; + FPEQ peq; + FVECT pt; + FVECT r0,r1,r2; + + Return the quadtree node containing pt. It is assumed that pt is in + the root node qt with ws vertices q0,q1,q2 and plane equation peq. + If r0 != NULL will return coordinates of node in (r0,r1,r2). +*/ + +extern QUADTREE qtRoot_point_locate(); +extern QUADTREE qtRoot_add_tri(); +extern QUADTREE qtRoot_remove_tri(); +extern QUADTREE qtAdd_tri(); +extern QUADTREE qtRoot_visit_tri_edges(); +extern QUADTREE qtRoot_trace_ray(); + + +#ifdef __cplusplus +} +#endif +#endif /* _RAD_SM_QTREE_H_ */ +