1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ SGI" */ |
4 |
< |
|
1 |
> |
/* RCSid: $Id$ */ |
2 |
|
/* |
3 |
|
* sm.h |
4 |
|
*/ |
5 |
|
|
6 |
< |
#ifndef _SM_H_ |
7 |
< |
#define _SM_H_ |
6 |
> |
#ifndef _RAD_SM_H_ |
7 |
> |
#define _RAD_SM_H_ |
8 |
|
|
9 |
|
#include "rhd_sample.h" |
10 |
+ |
#include "sm_qtree.h" |
11 |
+ |
#include "sm_stree.h" |
12 |
+ |
|
13 |
+ |
#ifdef __cplusplus |
14 |
+ |
extern "C" { |
15 |
+ |
#endif |
16 |
+ |
|
17 |
|
#define NEWSETS |
18 |
|
|
19 |
|
|
28 |
|
#define ON_E 3 |
29 |
|
#define IN_T 4 |
30 |
|
|
31 |
< |
#define S_REPLACE_EPS 0.04 /* if (distance on sphere between sample |
32 |
< |
and a base point) < S_REPLACE_EPS, |
33 |
< |
replace base: |
34 |
< |
*/ |
31 |
> |
#ifdef SMLFLT |
32 |
> |
#define VERT_EPS 2e-3 /* min edge length in radians */ |
33 |
> |
#define COS_VERT_EPS 0.999998 /* cos min edge length in radians */ |
34 |
> |
#define EDGE_EPS 2e-5 /* min distance until considered "on-edge"*/ |
35 |
> |
#define COLINEAR_EPS 1e-10 /* min sine of between edges angle :amount off PI */ |
36 |
> |
#else |
37 |
> |
#define VERT_EPS 5e-4 /* min edge length in radians */ |
38 |
> |
#define COS_VERT_EPS 0.999999875 /* cos min edge length in radians */ |
39 |
> |
#define EDGE_EPS 2e-7 /* min distance until considered "on-edge"*/ |
40 |
> |
#define COLINEAR_EPS 1e-10 /* min sine of between edges angle :amount off PI*/ |
41 |
> |
#endif |
42 |
> |
|
43 |
> |
#define EV_EPS EDGE_EPS /* Minimum edge-vertex distance */ |
44 |
> |
|
45 |
> |
|
46 |
|
#define S_REPLACE_SCALE (5.*5.) /* if (distance to new point squared) is |
47 |
< |
> (triangle edge length squared* |
48 |
< |
S_REPLACE_SCALE):for all edges/triangle |
49 |
< |
vertices: new point is puncture |
35 |
< |
point: dont add |
36 |
< |
*/ |
37 |
< |
#define S_REPLACE_TRI 2e-8 /* .052 radians to the sixth power */ |
47 |
> |
> (triangle edge length squared*S_REPLACE_SCALE):for all edges/ |
48 |
> |
triangle vertices: new point is puncture point: dont add*/ |
49 |
> |
#define S_REPLACE_TRI 2e-8 /* .052 radians to the sixth power */ |
50 |
|
|
39 |
– |
#define SQRT3_2 0.8660254 |
51 |
|
|
52 |
+ |
|
53 |
|
#define SM_DEFAULT 0 |
54 |
< |
#define SM_EXTRA_POINTS 162 |
54 |
> |
#define SM_BASE_POINTS 162 |
55 |
|
#define SM_BASE_TRIS 320 |
56 |
< |
#define SM_EXTRA_VERTS SM_EXTRA_POINTS |
56 |
> |
#define SM_BASE_VERTS SM_BASE_POINTS |
57 |
|
|
46 |
– |
#define SM_INC_PERCENT 0.60 /* If number of new triangles added |
47 |
– |
since last full redraw is > |
48 |
– |
(SM_INC_PERCENT * total triangles) |
49 |
– |
do full redraw instead of incremental |
50 |
– |
*/ |
51 |
– |
|
58 |
|
#define SM_VIEW_FRAC 0.1 |
59 |
|
|
60 |
+ |
#define SM_ALL_LEVELS -1 |
61 |
|
|
62 |
+ |
|
63 |
|
typedef int VERT; /* One triangle that vertex belongs to- the rest |
64 |
|
are derived by traversing neighbors */ |
65 |
|
|
66 |
|
typedef struct _EDGE { |
67 |
< |
int verts[2]; |
67 |
> |
S_ID verts[2]; |
68 |
|
int tris[2]; |
69 |
|
} EDGE; |
70 |
|
|
74 |
|
#define E_NTH_TRI(e,i) ((e>0)?Edges[(e)].tris[(i)]:Edges[-(e)].tris[(1-i)]) |
75 |
|
#define SET_E_NTH_TRI(e,i,v) if(e>0) Edges[(e)].tris[(i)]=(v); \ |
76 |
|
else Edges[-(e)].tris[(1-i)]=(v) |
77 |
< |
#define eClear_edges() (Ecnt = 0) |
77 |
> |
#define eClear_edges() (Ecnt = 0,free(Edges),Edges=NULL) |
78 |
|
|
79 |
|
#define FOR_ALL_EDGES(i) for((i)=1; (i) <= Ecnt; i++) |
80 |
< |
#define FOR_ALL_EDGES_FROM(e,i) for((i)=++e; (i) <= Ecnt; i++) |
80 |
> |
#define FOR_ALL_EDGES_FROM(e,i) for((i)=e+1; (i) <= Ecnt; i++) |
81 |
|
|
82 |
|
|
83 |
|
typedef struct _TRI { |
84 |
< |
int verts[3]; /* Ids into sample and vertex array for each vertex*/ |
84 |
> |
S_ID verts[3]; /* Ids into sample and vertex array for each vertex*/ |
85 |
|
int nbrs[3]; /* Ids for neighboring triangles: -1 if invalid */ |
86 |
|
}TRI; |
87 |
|
|
94 |
|
#define T_WHICH_V(t,i) \ |
95 |
|
(T_NTH_V(t,0)==(i)?0:T_NTH_V(t,1)==(i)?1:T_NTH_V(t,2)==(i)?2:-1) |
96 |
|
#define T_NEXT_FREE(t) ((t)->nbrs[0]) |
89 |
– |
#define T_NEXT_AVAILABLE(t) ((t)->nbrs[0]) |
97 |
|
#define T_VALID_FLAG(t) ((t)->nbrs[1]) |
98 |
|
#define T_IS_VALID(t) (T_VALID_FLAG(t)!=-1) |
99 |
|
#define T_FLAGS 4 |
104 |
|
STREE locator; /* spherical quadtree for point/triangle location */ |
105 |
|
int max_tris; /* Maximum number of triangles */ |
106 |
|
int num_tri; /* Current number of triangles */ |
100 |
– |
int sample_tris; /* Current number of non-base triangles*/ |
107 |
|
int free_tris; /* pointer to free_list */ |
102 |
– |
int available_tris; /* pointer to available_list */ |
108 |
|
int max_verts; /* Maximum number of vertices in the mesh */ |
109 |
|
TRI *tris; /* Pointer to list of triangle structs */ |
110 |
< |
VERT *verts; /* List of vertices */ |
106 |
< |
int4 *flags[T_FLAGS]; /* Bit 0 set if active(in current frustum) */ |
110 |
> |
int32 *flags[T_FLAGS]; /* Bit 0 set if active(in current frustum) */ |
111 |
|
/* Bit 1 set if not rendered since created */ |
112 |
|
/* Bit 2 set if base triangle */ |
113 |
|
}SM; |
122 |
|
#define SM_LOCATOR(m) (&((m)->locator)) |
123 |
|
#define SM_MAX_TRIS(m) ((m)->max_tris) |
124 |
|
#define SM_NUM_TRI(m) ((m)->num_tri) |
121 |
– |
#define SM_SAMPLE_TRIS(m) ((m)->sample_tris) |
125 |
|
#define SM_FREE_TRIS(m) ((m)->free_tris) |
123 |
– |
#define SM_AVAILABLE_TRIS(m) ((m)->available_tris) |
126 |
|
#define SM_MAX_VERTS(m) ((m)->max_verts) |
127 |
|
#define SM_TRIS(m) ((m)->tris) |
126 |
– |
#define SM_VERTS(m) ((m)->verts) |
128 |
|
#define SM_NTH_FLAGS(m,n) ((m)->flags[(n)]) |
129 |
|
#define SM_FLAGS(m) ((m)->flags) |
130 |
|
|
149 |
|
#define SM_CLR_NTH_T_BG(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_BG_FLAG) |
150 |
|
|
151 |
|
#define SM_NTH_TRI(m,n) (&(SM_TRIS(m)[(n)])) |
152 |
< |
#define SM_NTH_VERT(m,n) (SM_VERTS(m)[(n)]) |
152 |
> |
#define SM_NTH_VERT(m,n) S_NTH_INFO(SM_SAMP(m),n) |
153 |
|
|
154 |
|
#define SM_T_ID_VALID(s,t_id) T_IS_VALID(SM_NTH_TRI(s,t_id)) |
155 |
|
|
193 |
|
|
194 |
|
#define SM_FOR_ALL_SAMPLES(sm,i) for((i)=0;i < SM_NUM_SAMP(sm);(i)++) |
195 |
|
|
196 |
< |
#define smInit_locator(sm,c) (stInit(SM_LOCATOR(sm)), \ |
197 |
< |
ST_SET_CENTER(SM_LOCATOR(sm),c)) |
198 |
< |
#define smClear_locator(sm) stClear(SM_LOCATOR(sm)) |
196 |
> |
#define SM_FOR_ALL_VALID_TRIS(m,i) for((i)=0,(i)=smNext_valid_tri(m,i);(i)< \ |
197 |
> |
SM_NUM_TRI(m); (i)++,(i)= smNext_valid_tri(m,i)) |
198 |
> |
|
199 |
> |
#define SM_FOR_ALL_FLAGGED_TRIS(m,i,w,b) for(i=0,i=smNext_tri_flag_set(m,i,w,b);i < SM_NUM_TRI(m);i++,i=smNext_tri_flag_set(m,i,w,b)) |
200 |
> |
#define SM_FOR_ALL_ACTIVE_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,0) |
201 |
> |
#define smInit_locator(sm) stInit(SM_LOCATOR(sm)) |
202 |
|
#define smAlloc_locator(sm) stAlloc(SM_LOCATOR(sm)) |
203 |
< |
#define smFree_locator(sm) stClear(SM_LOCATOR(sm)) |
200 |
< |
#define smPointLocateCell(sm,pt) stPoint_locate(SM_LOCATOR(sm),pt) |
203 |
> |
#define smFree_locator(sm) stFree(SM_LOCATOR(sm)) |
204 |
|
#define smUnalloc_samp(sm,id) sUnalloc_samp(SM_SAMP(sm),id) |
205 |
+ |
#define smPoint_locate_cell(sm,pt) stPoint_locate(SM_LOCATOR(sm),pt) |
206 |
|
#define smFree_samples(sm) sFree(SM_SAMP(sm)) |
203 |
– |
#define smClear_samples(sm) sClear(SM_SAMP(sm)) |
207 |
|
#define smInit_samples(sm) sInit(SM_SAMP(sm)) |
208 |
|
|
209 |
< |
|
209 |
> |
#define SM_S_NTH_QT(sm,s_id) S_NTH_INFO1(SM_SAMP(sm),s_id) |
210 |
|
#define smClear_vert(sm,id) (SM_NTH_VERT(sm,id) = INVALID) |
211 |
|
|
212 |
+ |
#define freebuf(b) tempbuf(-1) |
213 |
+ |
|
214 |
|
typedef struct _RT_ARGS_{ |
215 |
|
FVECT orig,dir; |
216 |
|
int t_id; |
217 |
< |
OBJECT *os; |
217 |
> |
S_ID *os; |
218 |
|
}RT_ARGS; |
219 |
|
|
220 |
+ |
typedef struct _S_ARGS_{ |
221 |
+ |
S_ID s_id; |
222 |
+ |
S_ID n_id; |
223 |
+ |
}S_ARGS; |
224 |
|
|
225 |
+ |
|
226 |
|
typedef struct _ADD_ARGS { |
227 |
|
int t_id; |
228 |
< |
OBJECT *del_set; |
228 |
> |
S_ID *del_set; |
229 |
|
}ADD_ARGS; |
230 |
|
|
231 |
|
extern SM *smMesh; |
222 |
– |
extern int smNew_tri_cnt; |
232 |
|
extern double smDist_sum; |
233 |
|
|
234 |
|
|
270 |
|
* |
271 |
|
* Find the closest sample to the given ray. Return -1 on failure. |
272 |
|
* |
264 |
– |
* |
265 |
– |
* smClean() : display has been wiped clean |
266 |
– |
* |
267 |
– |
* Called after display has been effectively cleared, meaning that all |
268 |
– |
* geometry must be resent down the pipeline in the next call to smUpdate(). |
269 |
– |
* |
270 |
– |
* |
271 |
– |
* smUpdate(vp, qua) : update OpenGL output geometry for view vp |
272 |
– |
* VIEW *vp; : desired view |
273 |
– |
* int qua; : quality level (percentage on linear time scale) |
274 |
– |
* |
275 |
– |
* Draw new geometric representation using OpenGL calls. Assume that the |
276 |
– |
* view has already been set up and the correct frame buffer has been |
277 |
– |
* selected for drawing. The quality level is on a linear scale, where 100% |
278 |
– |
* is full (final) quality. It is not necessary to redraw geometry that has |
279 |
– |
* been output since the last call to smClean(). (The last view drawn will |
280 |
– |
* be vp==&odev.v each time.) |
273 |
|
*/ |
282 |
– |
#endif |
274 |
|
|
275 |
< |
|
276 |
< |
|
277 |
< |
|
278 |
< |
|
288 |
< |
|
289 |
< |
|
275 |
> |
#ifdef __cplusplus |
276 |
> |
} |
277 |
> |
#endif |
278 |
> |
#endif /* define _RAD_SM_H_ */ |
279 |
|
|