ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_geom.h
Revision: 3.5
Committed: Tue Oct 6 18:16:54 1998 UTC (25 years, 7 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.4: +21 -1 lines
Log Message:
new triangulate routine
added smTestSample to check for occlusion
added frustum culling before rebuild
changed base quadtree to use octahedron and created new point locate
added "sample active" flags and implemented LRU replacement
started handling case of too many triangles
set sizes are now unbounded
changed all quadtree pointers to quadtrees

File Contents

# Content
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
3 /* SCCSid "$SunId$ SGI" */
4
5 /*
6 * sm_geom.h
7 */
8
9 /* Assumes included after standard.h */
10
11 #include <values.h>
12
13 #define ZERO(x) ((x) < FTINY && (x) > -FTINY)
14 #define EQUAL(a,b) ZERO((a) - (b))
15
16 #ifndef TRUE
17 #define TRUE 1
18 #define FALSE 0
19 #endif
20
21 typedef struct _FPEQ {
22 FVECT n;
23 double d;
24 char x,y,z;
25 }FPEQ;
26
27 #define FP_N(f) ((f).n)
28 #define FP_D(f) ((f).d)
29 #define FP_X(f) ((f).x)
30 #define FP_Y(f) ((f).y)
31 #define FP_Z(f) ((f).z)
32
33 typedef long BCOORD;
34 typedef long BDIR;
35 typedef long TINT;
36 #define BITS_BCOORD (BITS(long)>>1)
37 #define SHIFT_MAXBCOORD (BITS_BCOORD-2)
38 #define MAXBCOORD (1L << SHIFT_MAXBCOORD)
39 #define MAXBCOORD2 (MAXBCOORD>>1)
40 #define MAXBDIR MAXBCOORD
41 #define MAXT MAXBCOORD
42 #define HUGET MAXLONG
43
44 #define M_2_3_PI PI*2/3
45
46 #ifndef INVALID
47 #define INVALID -1
48 #endif
49
50 #define GT_INVALID 0
51 #define GT_VERTEX 1
52 #define GT_EDGE 2
53 #define GT_FACE 4
54 #define GT_INTERIOR 8
55 #define GT_INTERSECT 16
56 #define GT_ADJACENT 32
57 #define GT_OUT 64
58
59 #define ZERO_VEC3(v) (ZERO(v[0]) && ZERO(v[1]) && ZERO(v[2]) )
60 #define EQUAL_VEC3(a,b) (EQUAL(a[0],b[0])&&EQUAL(a[1],b[1])&&EQUAL(a[2],b[2]))
61 #define NEGATE_VEC3(v) ((v)[0] *= -1.0,(v)[1] *= -1.0,(v)[2] *= -1.0)
62 #define COPY_VEC2(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1])
63 #define DIST(a,b) (sqrt(((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
64 ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
65 ((a)[2]-(b)[2])*((a)[2]-(b)[2])))
66 #define DIST_SQ(a,b) (((a)[0]-(b)[0])*((a)[0]-(b)[0]) + \
67 ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \
68 ((a)[2]-(b)[2])*((a)[2]-(b)[2]))
69
70 #define CROSS_VEC2(v1,v2) (((v1)[0]*(v2)[1]) - ((v1)[1]*(v2)[0]))
71 #define DOT_VEC2(v1,v2) ((v1)[0]*(v2)[0] + (v1)[1]*(v2)[1])
72
73 #define EDGE_MIDPOINT_VEC3(a,v1,v2) ((a)[0]=((v1)[0]+(v2)[0])*0.5, \
74 (a)[1]=((v1)[1]+(v2)[1])*0.5,(a)[2] = ((v1)[2]+(v2)[2])*0.5)
75
76 #define MIN_VEC3(v) ((v)[0]<(v)[1]?((v)[0]<(v)[2]?(v)[0]:v[2]): \
77 (v)[1]<(v)[2]?(v)[1]:(v)[2])
78 #define MAX3(a,b,c) (((b)>(a))?((b) > (c))?(b):(c):((a)>(c))?(a):(c))
79 #define MIN3(a,b,c) (((b)<(a))?((b) < (c))?(b):(c):((a)<(c))?(a):(c))
80 #define MAX(a,b) (((b)>(a))?(b):(a))
81 #define MIN(a,b) (((b)<(a))?(b):(a))
82
83 #define SUM_3VEC3(r,a,b,c) ((r)[0]=(a)[0]+(b)[0]+(c)[0], \
84 (r)[1]=(a)[1]+(b)[1]+(c)[1],(r)[2]=(a)[2]+(b)[2]+(c)[2])
85
86 #define NTH_BIT(n,i) ((n) & (1<<(i)))
87 #define SET_NTH_BIT(n,i) ((n) |= (1<<(i)))
88
89
90 /* int convex_angle(FVECT v0,FVECT v1,FVECT v2) */
91 /* void triangle_centroid(FVECT v0,FVECT v1,FVECT v2,FVECT c) */
92 /* void triangle_plane_equation(FVECT v0,FVECT v1,FVECT v2,FVECT n,double *nd,
93 char norm) */
94 /* int vec3_equal(FVECT v1,v2) */
95 /* int point_relative_to_plane(FVECT p,FVECT n, double nd) */
96 /* int point_in_circle(FVECT p,FVECT p0,FVECT p1) */
97 /* int intersect_line_plane(FVECT r,FVECT p1,FVECT p2,float *plane) */
98 /* int point_in_cone(FVECT p,FVECT p1,FVECT p2,FVECT p3,FVECT p4) */
99 /* void point_on_sphere(FVECT ps,FVECT p,FVECT c) */
100 /* int test_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,FVECT p,
101 FVECT n,char *nset,char *which,char sides[3]) */
102 /* int test_single_point_against_spherical_tri(FVECT v0,FVECT v1,FVECT v2,
103 FVECT p,char *which )*/
104 /* int test_vertices_for_tri_inclusion(FVECT tri[3],FVECT pts[3],char *nset,
105 FVECT n[3],FVECT avg,char pt_sides[3][3]); */
106 /* void set_sidedness_tests(FVECT tri[3],FVECT pts[3],char test[3],
107 char sides[3][3],char nset,FVECT n[3])
108 */
109 /* int cs_spherical_edge_edge_test(FVECT n[2][3],int i,int j,FVECT avg[2]) */
110 /* int spherical_tri_tri_intersect(FVECT a1,FVECT a2,FVECT a3,
111 FVECT b1,FVECT b2,FVECT b3) */
112
113 /* void calculate_view_frustum(FVECT vp,hv,vv,double horiz,vert,near,far,
114 FVECT fnear[4],FVECT ffar[4])
115 */
116 /* double triangle_normal_Newell(FVECT v0,FVECT v1,FVECT v2,FVECT n,char n)*/
117 double tri_normal();
118 /* double spherical_edge_normal(FVECT v0,FVECT v1,FVECT n,char norm) */
119 double spherical_edge_normal();
120
121 #define point_in_stri_n(n0,n1,n2,p) \
122 ((DOT(n0,p)<=0.0)&&(DOT(n1,p)<=0.0)&&(DOT(n2,p)<=0.0))
123
124 #define PT_ON_PLANE(p,peq) (DOT(FP_N(peq),p)+FP_D(peq))