--- ray/src/hd/sm.h 1998/10/06 18:16:54 3.4 +++ ray/src/hd/sm.h 1999/03/05 16:33:17 3.9 @@ -10,6 +10,7 @@ #define _SM_H_ #include "rhd_sample.h" +#define NEWSETS #ifndef TRUE @@ -17,19 +18,42 @@ #define FALSE 0 #endif -#define S_REPLACE_EPS 0.06 -#define S_REPLACE_SCALE 10.0 +#define ON_V 1 +#define ON_P 2 +#define ON_E 3 +#define IN_T 4 + +#define S_REPLACE_EPS 0.04 /* if (distance on sphere between sample + and a base point) < S_REPLACE_EPS, + replace base: + */ +#define S_REPLACE_SCALE (5.*5.) /* if (distance to new point squared) is + > (triangle edge length squared* + S_REPLACE_SCALE):for all edges/triangle + vertices: new point is puncture + point: dont add + */ +#define S_REPLACE_TRI 2e-8 /* .052 radians to the sixth power */ + #define SQRT3_2 0.8660254 #define SM_DEFAULT 0 -#define SM_EXTRA_POINTS 8 +#define SM_EXTRA_POINTS 162 +#define SM_BASE_TRIS 320 #define SM_EXTRA_VERTS SM_EXTRA_POINTS -#define SM_INC_PERCENT 0.60 +#define SM_INC_PERCENT 0.60 /* If number of new triangles added + since last full redraw is > + (SM_INC_PERCENT * total triangles) + do full redraw instead of incremental + */ + #define SM_VIEW_FRAC 0.1 +#define SM_ALL_LEVELS -1 + typedef int VERT; /* One triangle that vertex belongs to- the rest are derived by traversing neighbors */ @@ -64,9 +88,10 @@ typedef struct _TRI { #define T_WHICH_V(t,i) \ (T_NTH_V(t,0)==(i)?0:T_NTH_V(t,1)==(i)?1:T_NTH_V(t,2)==(i)?2:-1) #define T_NEXT_FREE(t) ((t)->nbrs[0]) +#define T_NEXT_AVAILABLE(t) ((t)->nbrs[0]) #define T_VALID_FLAG(t) ((t)->nbrs[1]) #define T_IS_VALID(t) (T_VALID_FLAG(t)!=-1) -#define T_FLAGS 3 +#define T_FLAGS 4 typedef struct _SM { FVECT view_center; /* Canonical view center defining unit sphere */ @@ -76,6 +101,7 @@ typedef struct _SM { int num_tri; /* Current number of triangles */ int sample_tris; /* Current number of non-base triangles*/ int free_tris; /* pointer to free_list */ + int available_tris; /* pointer to available_list */ int max_verts; /* Maximum number of vertices in the mesh */ TRI *tris; /* Pointer to list of triangle structs */ VERT *verts; /* List of vertices */ @@ -87,6 +113,7 @@ typedef struct _SM { #define T_ACTIVE_FLAG 0 #define T_NEW_FLAG 1 #define T_BASE_FLAG 2 +#define T_BG_FLAG 3 #define SM_VIEW_CENTER(m) ((m)->view_center) #define SM_SAMP(m) ((m)->samples) @@ -95,6 +122,7 @@ typedef struct _SM { #define SM_NUM_TRI(m) ((m)->num_tri) #define SM_SAMPLE_TRIS(m) ((m)->sample_tris) #define SM_FREE_TRIS(m) ((m)->free_tris) +#define SM_AVAILABLE_TRIS(m) ((m)->available_tris) #define SM_MAX_VERTS(m) ((m)->max_verts) #define SM_TRIS(m) ((m)->tris) #define SM_VERTS(m) ((m)->verts) @@ -109,26 +137,33 @@ typedef struct _SM { #define SM_IS_NTH_T_ACTIVE(sm,n) SM_IS_NTH_T_FLAG(sm,n,T_ACTIVE_FLAG) #define SM_IS_NTH_T_BASE(sm,n) SM_IS_NTH_T_FLAG(sm,n,T_BASE_FLAG) #define SM_IS_NTH_T_NEW(sm,n) SM_IS_NTH_T_FLAG(sm,n,T_NEW_FLAG) +#define SM_IS_NTH_T_BG(sm,n) SM_IS_NTH_T_FLAG(sm,n,T_BG_FLAG) #define SM_SET_NTH_T_ACTIVE(sm,n) SM_SET_NTH_T_FLAG(sm,n,T_ACTIVE_FLAG) #define SM_SET_NTH_T_BASE(sm,n) SM_SET_NTH_T_FLAG(sm,n,T_BASE_FLAG) #define SM_SET_NTH_T_NEW(sm,n) SM_SET_NTH_T_FLAG(sm,n,T_NEW_FLAG) +#define SM_SET_NTH_T_BG(sm,n) SM_SET_NTH_T_FLAG(sm,n,T_BG_FLAG) #define SM_CLR_NTH_T_ACTIVE(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_ACTIVE_FLAG) #define SM_CLR_NTH_T_BASE(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_BASE_FLAG) #define SM_CLR_NTH_T_NEW(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_NEW_FLAG) +#define SM_CLR_NTH_T_BG(sm,n) SM_CLR_NTH_T_FLAG(sm,n,T_BG_FLAG) #define SM_NTH_TRI(m,n) (&(SM_TRIS(m)[(n)])) #define SM_NTH_VERT(m,n) (SM_VERTS(m)[(n)]) + +#define SM_T_ID_VALID(s,t_id) T_IS_VALID(SM_NTH_TRI(s,t_id)) + #define SM_MAX_SAMP(m) S_MAX_SAMP(SM_SAMP(m)) #define SM_MAX_POINTS(m) S_MAX_POINTS(SM_SAMP(m)) #define SM_SAMP_BASE(m) S_BASE(SM_SAMP(m)) #define SM_NTH_WV(m,i) S_NTH_W_PT(SM_SAMP(m),i) #define SM_NTH_W_DIR(m,i) S_NTH_W_DIR(SM_SAMP(m),i) -#define SM_DIR_ID(m,i) (SM_NTH_W_DIR(m,i)==-1) +#define SM_DIR_ID(m,i) (!SM_BASE_ID(m,i) && SM_NTH_W_DIR(m,i)==-1) #define SM_NTH_RGB(m,i) S_NTH_RGB(SM_SAMP(m),i) #define SM_RGB(m) S_RGB(SM_SAMP(m)) +#define SM_WP(m) S_W_PT(SM_SAMP(m)) #define SM_BRT(m) S_BRT(SM_SAMP(m)) #define SM_NTH_BRT(m,i) S_NTH_BRT(SM_SAMP(m),i) #define SM_CHR(m) S_CHR(SM_SAMP(m)) @@ -138,20 +173,6 @@ typedef struct _SM { #define SM_ALLOWED_VIEW_CHANGE(m) (SM_NUM_SAMP(m)/smDist_sum*SM_VIEW_FRAC) -#define SM_FOR_ALL_FLAGGED_TRIS(m,i,w,b) for(i=smNext_tri_flag_set(m,0,w,b); \ -i < SM_NUM_TRI(m); i=smNext_tri_flag_set(m,i+1,w,b)) - -#define SM_FOR_ALL_ACTIVE_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,0) -#define SM_FOR_ALL_NEW_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_NEW_FLAG,0) -#define SM_FOR_ALL_BASE_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_BASE_FLAG,0) -#define SM_FOR_ALL_VALID_TRIS(m,i) for(i=smNext_valid_tri(m,0); \ -i < SM_NUM_TRI(m); i=smNext_valid_tri(m,i+1)) - -#define SM_FOR_ALL_ACTIVE_FG_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,1) - -#define SM_FOR_ALL_ACTIVE_BG_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,2) - - #define SM_FOR_ALL_ADJACENT_TRIS(sm,id,t) for(t=smTri_next_ccw_nbr(sm,t,id); \ t!=SM_NTH_TRI(sm,SM_NTH_VERT(sm,id)); t=smTri_next_ccw_nbr(sm,t,id)) @@ -187,13 +208,6 @@ t!=SM_NTH_TRI(sm,SM_NTH_VERT(sm,id)); t=smTri_next_ccw #define smClear_vert(sm,id) (SM_NTH_VERT(sm,id) = INVALID) -#define SQRT3_INV 0.5773502692 - -typedef struct _T_DEPTH { - int tri; - double depth; -}T_DEPTH; - typedef struct _RT_ARGS_{ FVECT orig,dir; int t_id; @@ -217,6 +231,7 @@ extern VIEW Current_View; extern int Pick_tri,Picking,Pick_samp; extern FVECT Pick_point[500],Pick_origin,Pick_dir; extern FVECT Pick_v0[500],Pick_v1[500],Pick_v2[500]; +extern int Pick_q[500]; extern FVECT P0,P1,P2; extern int Pick_cnt; extern FVECT FrustumNear[4],FrustumFar[4]; @@ -266,7 +281,6 @@ extern FVECT FrustumNear[4],FrustumFar[4]; * been output since the last call to smClean(). (The last view drawn will * be vp==&odev.v each time.) */ - #endif