ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm.h
(Generate patch)

Comparing ray/src/hd/sm.h (file contents):
Revision 3.9 by gwlarson, Fri Mar 5 16:33:17 1999 UTC vs.
Revision 3.10 by gwlarson, Thu Jun 10 15:22:22 1999 UTC

# Line 8 | Line 8
8  
9   #ifndef _SM_H_
10   #define _SM_H_
11
11   #include "rhd_sample.h"
12 + #include "sm_qtree.h"
13 + #include "sm_stree.h"
14   #define NEWSETS
15  
16  
# Line 24 | Line 25
25   #define ON_E 3
26   #define IN_T 4
27  
28 < #define S_REPLACE_EPS 0.04      /* if (distance on sphere between sample
29 <                                     and a base point) < S_REPLACE_EPS,
30 <                                     replace base:
31 <                                     */
28 > #ifndef LOWRES
29 > #define VERT_EPS 5e-4 /* min edge length in radians */
30 > #define COS_VERT_EPS 0.999999875 /* cos min edge length in radians */
31 > #define EDGE_EPS 2e-7 /* min distance until considered "on-edge"*/
32 > #define COLINEAR_EPS 1e-10 /* minimum sine of between edges angle :amount off
33 >                             180degrees
34 >                             */
35 > #define EQUALITY_EPS 1e-10
36 > #else
37 > #define VERT_EPS 2e-3 /* min edge length in radians */
38 > #define COS_VERT_EPS 0.999998 /* cos min edge length in radians */
39 > #define EDGE_EPS 2e-5 /* min distance until considered "on-edge"*/
40 > #define COLINEAR_EPS 1e-10 /* minimum sine of between edges angle :amount off
41 >                             180degrees
42 >                             */
43 > #define EQUALITY_EPS 1e-10
44 > #endif
45 >
46 > #define EV_EPS EDGE_EPS      /* Minimum edge-vertex distance */
47 >
48 >
49   #define S_REPLACE_SCALE (5.*5.)   /* if (distance to new point squared) is
50 <                                     > (triangle edge length squared*
51 <                                     S_REPLACE_SCALE):for all edges/triangle
52 <                                     vertices: new point is puncture
35 <                                     point: dont add
36 <                                   */
37 < #define S_REPLACE_TRI 2e-8              /* .052 radians to the sixth power */
50 >         > (triangle edge length squared*S_REPLACE_SCALE):for all edges/
51 >         triangle vertices: new point is puncture point: dont add*/
52 > #define S_REPLACE_TRI 2e-8              /* .052 radians to the sixth power */
53  
39 #define SQRT3_2 0.8660254
54  
55 +
56   #define SM_DEFAULT 0
57 < #define SM_EXTRA_POINTS 162
57 > #define SM_BASE_POINTS 162
58   #define SM_BASE_TRIS 320
59 < #define SM_EXTRA_VERTS  SM_EXTRA_POINTS
59 > #define SM_BASE_VERTS  SM_BASE_POINTS
60  
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
61   #define SM_VIEW_FRAC   0.1
62  
63   #define  SM_ALL_LEVELS -1
# Line 68 | Line 77 | typedef struct _EDGE {
77   #define E_NTH_TRI(e,i)  ((e>0)?Edges[(e)].tris[(i)]:Edges[-(e)].tris[(1-i)])
78   #define SET_E_NTH_TRI(e,i,v) if(e>0) Edges[(e)].tris[(i)]=(v); \
79                                else Edges[-(e)].tris[(1-i)]=(v)
80 < #define eClear_edges() (Ecnt = 0)
80 > #define eClear_edges() (Ecnt = 0,free(Edges),Edges=NULL)
81  
82   #define FOR_ALL_EDGES(i) for((i)=1; (i) <= Ecnt; i++)
83 < #define FOR_ALL_EDGES_FROM(e,i) for((i)=++e; (i) <= Ecnt; i++)
83 > #define FOR_ALL_EDGES_FROM(e,i) for((i)=e+1; (i) <= Ecnt; i++)
84  
85  
86   typedef struct _TRI {
# Line 88 | Line 97 | typedef struct _TRI {
97   #define T_WHICH_V(t,i)     \
98           (T_NTH_V(t,0)==(i)?0:T_NTH_V(t,1)==(i)?1:T_NTH_V(t,2)==(i)?2:-1)
99   #define T_NEXT_FREE(t) ((t)->nbrs[0])
91 #define T_NEXT_AVAILABLE(t) ((t)->nbrs[0])
100   #define T_VALID_FLAG(t) ((t)->nbrs[1])
101   #define T_IS_VALID(t)  (T_VALID_FLAG(t)!=-1)
102   #define T_FLAGS 4
# Line 99 | Line 107 | typedef struct _SM {
107      STREE locator;        /* spherical quadtree for point/triangle location */
108      int max_tris;         /* Maximum number of triangles */
109      int num_tri;          /* Current number of triangles */
102    int sample_tris;      /* Current number of non-base triangles*/
110      int free_tris;        /* pointer to free_list */
104    int available_tris;   /* pointer to available_list */
111      int max_verts;        /* Maximum number of vertices in the mesh */
112      TRI *tris;            /* Pointer to list of triangle structs */
107    VERT *verts;          /* List of vertices */
113      int4 *flags[T_FLAGS]; /* Bit 0 set if active(in current frustum) */
114                            /* Bit 1 set if not rendered since created */
115                            /* Bit 2 set if base triangle */
# Line 120 | Line 125 | typedef struct _SM {
125   #define SM_LOCATOR(m)                 (&((m)->locator))
126   #define SM_MAX_TRIS(m)                ((m)->max_tris)
127   #define SM_NUM_TRI(m)                 ((m)->num_tri)
123 #define SM_SAMPLE_TRIS(m)                 ((m)->sample_tris)
128   #define SM_FREE_TRIS(m)               ((m)->free_tris)
125 #define SM_AVAILABLE_TRIS(m)          ((m)->available_tris)
129   #define SM_MAX_VERTS(m)               ((m)->max_verts)
130   #define SM_TRIS(m)                    ((m)->tris)
128 #define SM_VERTS(m)                   ((m)->verts)
131   #define SM_NTH_FLAGS(m,n)             ((m)->flags[(n)])
132   #define SM_FLAGS(m)                   ((m)->flags)
133  
# Line 150 | Line 152 | typedef struct _SM {
152   #define SM_CLR_NTH_T_BG(sm,n)       SM_CLR_NTH_T_FLAG(sm,n,T_BG_FLAG)
153  
154   #define SM_NTH_TRI(m,n)               (&(SM_TRIS(m)[(n)]))
155 < #define SM_NTH_VERT(m,n)              (SM_VERTS(m)[(n)])
155 > #define SM_NTH_VERT(m,n)              S_NTH_INFO(SM_SAMP(m),n)
156  
157   #define SM_T_ID_VALID(s,t_id) T_IS_VALID(SM_NTH_TRI(s,t_id))
158  
# Line 194 | Line 196 | t!=SM_NTH_TRI(sm,SM_NTH_VERT(sm,id)); t=smTri_next_ccw
196  
197   #define SM_FOR_ALL_SAMPLES(sm,i) for((i)=0;i < SM_NUM_SAMP(sm);(i)++)
198  
199 < #define smInit_locator(sm,c)    (stInit(SM_LOCATOR(sm)), \
200 <                                 ST_SET_CENTER(SM_LOCATOR(sm),c))
201 < #define smClear_locator(sm)    stClear(SM_LOCATOR(sm))
199 > #define SM_FOR_ALL_VALID_TRIS(m,i) for((i)=0,(i)=smNext_valid_tri(m,i);(i)< \
200 > SM_NUM_TRI(m); (i)++,(i)= smNext_valid_tri(m,i))
201 >
202 > #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))
203 > #define SM_FOR_ALL_ACTIVE_TRIS(m,i) SM_FOR_ALL_FLAGGED_TRIS(m,i,T_ACTIVE_FLAG,0)
204 > #define smInit_locator(sm)    stInit(SM_LOCATOR(sm))
205   #define smAlloc_locator(sm)   stAlloc(SM_LOCATOR(sm))
206 < #define smFree_locator(sm)   stClear(SM_LOCATOR(sm))
202 < #define smPointLocateCell(sm,pt)  stPoint_locate(SM_LOCATOR(sm),pt)
206 > #define smFree_locator(sm)   stFree(SM_LOCATOR(sm))
207   #define smUnalloc_samp(sm,id)  sUnalloc_samp(SM_SAMP(sm),id)
208 + #define smPoint_locate_cell(sm,pt)  stPoint_locate(SM_LOCATOR(sm),pt)
209   #define smFree_samples(sm)     sFree(SM_SAMP(sm))
205 #define smClear_samples(sm)    sClear(SM_SAMP(sm))
210   #define smInit_samples(sm)     sInit(SM_SAMP(sm))
211  
212 <
212 > #define SM_S_NTH_QT(sm,s_id)       S_NTH_INFO1(SM_SAMP(sm),s_id)
213   #define smClear_vert(sm,id)    (SM_NTH_VERT(sm,id) = INVALID)
214  
215 + #define freebuf(b)  tempbuf(-1)
216 +
217   typedef struct _RT_ARGS_{
218    FVECT orig,dir;
219    int t_id;
220    OBJECT *os;
221   }RT_ARGS;
222  
223 + typedef struct _S_ARGS_{
224 +  int s_id,n_id;
225 + }S_ARGS;
226  
227 +
228   typedef struct _ADD_ARGS {
229    int t_id;
230    OBJECT *del_set;
231   }ADD_ARGS;
232  
233   extern SM *smMesh;
224 extern int smNew_tri_cnt;
234   extern double smDist_sum;
235  
236  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines