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_ |
11 |
– |
|
8 |
|
#include "rhd_sample.h" |
9 |
+ |
#include "sm_qtree.h" |
10 |
+ |
#include "sm_stree.h" |
11 |
|
#define NEWSETS |
12 |
|
|
13 |
|
|
22 |
|
#define ON_E 3 |
23 |
|
#define IN_T 4 |
24 |
|
|
25 |
< |
#define S_REPLACE_EPS 0.04 /* if (distance on sphere between sample |
26 |
< |
and a base point) < S_REPLACE_EPS, |
27 |
< |
replace base: |
28 |
< |
*/ |
25 |
> |
#ifdef SMLFLT |
26 |
> |
#define VERT_EPS 2e-3 /* min edge length in radians */ |
27 |
> |
#define COS_VERT_EPS 0.999998 /* cos min edge length in radians */ |
28 |
> |
#define EDGE_EPS 2e-5 /* min distance until considered "on-edge"*/ |
29 |
> |
#define COLINEAR_EPS 1e-10 /* min sine of between edges angle :amount off PI */ |
30 |
> |
#else |
31 |
> |
#define VERT_EPS 5e-4 /* min edge length in radians */ |
32 |
> |
#define COS_VERT_EPS 0.999999875 /* cos min edge length in radians */ |
33 |
> |
#define EDGE_EPS 2e-7 /* min distance until considered "on-edge"*/ |
34 |
> |
#define COLINEAR_EPS 1e-10 /* min sine of between edges angle :amount off PI*/ |
35 |
> |
#endif |
36 |
> |
|
37 |
> |
#define EV_EPS EDGE_EPS /* Minimum edge-vertex distance */ |
38 |
> |
|
39 |
> |
|
40 |
|
#define S_REPLACE_SCALE (5.*5.) /* if (distance to new point squared) is |
41 |
< |
> (triangle edge length squared* |
42 |
< |
S_REPLACE_SCALE):for all edges/triangle |
43 |
< |
vertices: new point is puncture |
35 |
< |
point: dont add |
36 |
< |
*/ |
37 |
< |
#define S_REPLACE_TRI 2e-8 /* .052 radians to the sixth power */ |
41 |
> |
> (triangle edge length squared*S_REPLACE_SCALE):for all edges/ |
42 |
> |
triangle vertices: new point is puncture point: dont add*/ |
43 |
> |
#define S_REPLACE_TRI 2e-8 /* .052 radians to the sixth power */ |
44 |
|
|
39 |
– |
#define SQRT3_2 0.8660254 |
45 |
|
|
46 |
+ |
|
47 |
|
#define SM_DEFAULT 0 |
48 |
< |
#define SM_EXTRA_POINTS 162 |
48 |
> |
#define SM_BASE_POINTS 162 |
49 |
|
#define SM_BASE_TRIS 320 |
50 |
< |
#define SM_EXTRA_VERTS SM_EXTRA_POINTS |
50 |
> |
#define SM_BASE_VERTS SM_BASE_POINTS |
51 |
|
|
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 |
– |
|
52 |
|
#define SM_VIEW_FRAC 0.1 |
53 |
|
|
54 |
|
#define SM_ALL_LEVELS -1 |
58 |
|
are derived by traversing neighbors */ |
59 |
|
|
60 |
|
typedef struct _EDGE { |
61 |
< |
int verts[2]; |
61 |
> |
S_ID verts[2]; |
62 |
|
int tris[2]; |
63 |
|
} EDGE; |
64 |
|
|
68 |
|
#define E_NTH_TRI(e,i) ((e>0)?Edges[(e)].tris[(i)]:Edges[-(e)].tris[(1-i)]) |
69 |
|
#define SET_E_NTH_TRI(e,i,v) if(e>0) Edges[(e)].tris[(i)]=(v); \ |
70 |
|
else Edges[-(e)].tris[(1-i)]=(v) |
71 |
< |
#define eClear_edges() (Ecnt = 0) |
71 |
> |
#define eClear_edges() (Ecnt = 0,free(Edges),Edges=NULL) |
72 |
|
|
73 |
|
#define FOR_ALL_EDGES(i) for((i)=1; (i) <= Ecnt; i++) |
74 |
< |
#define FOR_ALL_EDGES_FROM(e,i) for((i)=++e; (i) <= Ecnt; i++) |
74 |
> |
#define FOR_ALL_EDGES_FROM(e,i) for((i)=e+1; (i) <= Ecnt; i++) |
75 |
|
|
76 |
|
|
77 |
|
typedef struct _TRI { |
78 |
< |
int verts[3]; /* Ids into sample and vertex array for each vertex*/ |
78 |
> |
S_ID verts[3]; /* Ids into sample and vertex array for each vertex*/ |
79 |
|
int nbrs[3]; /* Ids for neighboring triangles: -1 if invalid */ |
80 |
|
}TRI; |
81 |
|
|
88 |
|
#define T_WHICH_V(t,i) \ |
89 |
|
(T_NTH_V(t,0)==(i)?0:T_NTH_V(t,1)==(i)?1:T_NTH_V(t,2)==(i)?2:-1) |
90 |
|
#define T_NEXT_FREE(t) ((t)->nbrs[0]) |
91 |
– |
#define T_NEXT_AVAILABLE(t) ((t)->nbrs[0]) |
91 |
|
#define T_VALID_FLAG(t) ((t)->nbrs[1]) |
92 |
|
#define T_IS_VALID(t) (T_VALID_FLAG(t)!=-1) |
93 |
|
#define T_FLAGS 4 |
98 |
|
STREE locator; /* spherical quadtree for point/triangle location */ |
99 |
|
int max_tris; /* Maximum number of triangles */ |
100 |
|
int num_tri; /* Current number of triangles */ |
102 |
– |
int sample_tris; /* Current number of non-base triangles*/ |
101 |
|
int free_tris; /* pointer to free_list */ |
104 |
– |
int available_tris; /* pointer to available_list */ |
102 |
|
int max_verts; /* Maximum number of vertices in the mesh */ |
103 |
|
TRI *tris; /* Pointer to list of triangle structs */ |
107 |
– |
VERT *verts; /* List of vertices */ |
104 |
|
int4 *flags[T_FLAGS]; /* Bit 0 set if active(in current frustum) */ |
105 |
|
/* Bit 1 set if not rendered since created */ |
106 |
|
/* Bit 2 set if base triangle */ |
116 |
|
#define SM_LOCATOR(m) (&((m)->locator)) |
117 |
|
#define SM_MAX_TRIS(m) ((m)->max_tris) |
118 |
|
#define SM_NUM_TRI(m) ((m)->num_tri) |
123 |
– |
#define SM_SAMPLE_TRIS(m) ((m)->sample_tris) |
119 |
|
#define SM_FREE_TRIS(m) ((m)->free_tris) |
125 |
– |
#define SM_AVAILABLE_TRIS(m) ((m)->available_tris) |
120 |
|
#define SM_MAX_VERTS(m) ((m)->max_verts) |
121 |
|
#define SM_TRIS(m) ((m)->tris) |
128 |
– |
#define SM_VERTS(m) ((m)->verts) |
122 |
|
#define SM_NTH_FLAGS(m,n) ((m)->flags[(n)]) |
123 |
|
#define SM_FLAGS(m) ((m)->flags) |
124 |
|
|
143 |
|
#define SM_CLR_NTH_T_BG(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_BG_FLAG) |
144 |
|
|
145 |
|
#define SM_NTH_TRI(m,n) (&(SM_TRIS(m)[(n)])) |
146 |
< |
#define SM_NTH_VERT(m,n) (SM_VERTS(m)[(n)]) |
146 |
> |
#define SM_NTH_VERT(m,n) S_NTH_INFO(SM_SAMP(m),n) |
147 |
|
|
148 |
|
#define SM_T_ID_VALID(s,t_id) T_IS_VALID(SM_NTH_TRI(s,t_id)) |
149 |
|
|
187 |
|
|
188 |
|
#define SM_FOR_ALL_SAMPLES(sm,i) for((i)=0;i < SM_NUM_SAMP(sm);(i)++) |
189 |
|
|
190 |
< |
#define smInit_locator(sm,c) (stInit(SM_LOCATOR(sm)), \ |
191 |
< |
ST_SET_CENTER(SM_LOCATOR(sm),c)) |
192 |
< |
#define smClear_locator(sm) stClear(SM_LOCATOR(sm)) |
190 |
> |
#define SM_FOR_ALL_VALID_TRIS(m,i) for((i)=0,(i)=smNext_valid_tri(m,i);(i)< \ |
191 |
> |
SM_NUM_TRI(m); (i)++,(i)= smNext_valid_tri(m,i)) |
192 |
> |
|
193 |
> |
#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)) |
194 |
> |
#define SM_FOR_ALL_ACTIVE_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,0) |
195 |
> |
#define smInit_locator(sm) stInit(SM_LOCATOR(sm)) |
196 |
|
#define smAlloc_locator(sm) stAlloc(SM_LOCATOR(sm)) |
197 |
< |
#define smFree_locator(sm) stClear(SM_LOCATOR(sm)) |
202 |
< |
#define smPointLocateCell(sm,pt) stPoint_locate(SM_LOCATOR(sm),pt) |
197 |
> |
#define smFree_locator(sm) stFree(SM_LOCATOR(sm)) |
198 |
|
#define smUnalloc_samp(sm,id) sUnalloc_samp(SM_SAMP(sm),id) |
199 |
+ |
#define smPoint_locate_cell(sm,pt) stPoint_locate(SM_LOCATOR(sm),pt) |
200 |
|
#define smFree_samples(sm) sFree(SM_SAMP(sm)) |
205 |
– |
#define smClear_samples(sm) sClear(SM_SAMP(sm)) |
201 |
|
#define smInit_samples(sm) sInit(SM_SAMP(sm)) |
202 |
|
|
203 |
< |
|
203 |
> |
#define SM_S_NTH_QT(sm,s_id) S_NTH_INFO1(SM_SAMP(sm),s_id) |
204 |
|
#define smClear_vert(sm,id) (SM_NTH_VERT(sm,id) = INVALID) |
205 |
|
|
206 |
+ |
#define freebuf(b) tempbuf(-1) |
207 |
+ |
|
208 |
|
typedef struct _RT_ARGS_{ |
209 |
|
FVECT orig,dir; |
210 |
|
int t_id; |
211 |
< |
OBJECT *os; |
211 |
> |
S_ID *os; |
212 |
|
}RT_ARGS; |
213 |
|
|
214 |
+ |
typedef struct _S_ARGS_{ |
215 |
+ |
S_ID s_id; |
216 |
+ |
S_ID n_id; |
217 |
+ |
}S_ARGS; |
218 |
|
|
219 |
+ |
|
220 |
|
typedef struct _ADD_ARGS { |
221 |
|
int t_id; |
222 |
< |
OBJECT *del_set; |
222 |
> |
S_ID *del_set; |
223 |
|
}ADD_ARGS; |
224 |
|
|
225 |
|
extern SM *smMesh; |
224 |
– |
extern int smNew_tri_cnt; |
226 |
|
extern double smDist_sum; |
227 |
|
|
228 |
|
|
264 |
|
* |
265 |
|
* Find the closest sample to the given ray. Return -1 on failure. |
266 |
|
* |
266 |
– |
* |
267 |
– |
* smClean() : display has been wiped clean |
268 |
– |
* |
269 |
– |
* Called after display has been effectively cleared, meaning that all |
270 |
– |
* geometry must be resent down the pipeline in the next call to smUpdate(). |
271 |
– |
* |
272 |
– |
* |
273 |
– |
* smUpdate(vp, qua) : update OpenGL output geometry for view vp |
274 |
– |
* VIEW *vp; : desired view |
275 |
– |
* int qua; : quality level (percentage on linear time scale) |
276 |
– |
* |
277 |
– |
* Draw new geometric representation using OpenGL calls. Assume that the |
278 |
– |
* view has already been set up and the correct frame buffer has been |
279 |
– |
* selected for drawing. The quality level is on a linear scale, where 100% |
280 |
– |
* is full (final) quality. It is not necessary to redraw geometry that has |
281 |
– |
* been output since the last call to smClean(). (The last view drawn will |
282 |
– |
* be vp==&odev.v each time.) |
267 |
|
*/ |
268 |
|
#endif |
269 |
|
|