16 |
|
#include "sm_flag.h" |
17 |
|
#include "sm_list.h" |
18 |
|
#include "sm_geom.h" |
19 |
– |
#include "sm_qtree.h" |
20 |
– |
#include "sm_stree.h" |
19 |
|
#include "sm.h" |
20 |
|
|
21 |
< |
static int smClean_notify = TRUE; /*If true:Do full redraw on next update*/ |
21 |
> |
int smClean_notify = TRUE; /*If true:Do full redraw on next update*/ |
22 |
|
static int smCompute_mapping = TRUE;/*If true:re-tonemap on next update */ |
23 |
|
static int smIncremental = FALSE; /*If true: there has been incremental |
24 |
|
rendering since last full draw */ |
25 |
+ |
#define MAX_NEW_TRIS 1000 |
26 |
|
#define SM_RENDER_FG 0 /* Render foreground tris only*/ |
27 |
|
#define SM_RENDER_BG 1 /* Render background tris only */ |
28 |
< |
#define SM_RENDER_MIXED 4 /* Render mixed tris only */ |
29 |
< |
#define SM_RENDER_CULL 8 /* Perform view frustum culling */ |
30 |
< |
#define BASE 1 |
32 |
< |
#define DIR 2 |
28 |
> |
#define SM_RENDER_CULL 8 /* Perform view frustum culling */ |
29 |
> |
#define BASE 1 /* Indicates base triangle */ |
30 |
> |
#define DIR 2 /* Indicates triangle w/directional pts*/ |
31 |
|
/* FOR DISPLAY LIST RENDERING: **********************************************/ |
32 |
|
#define SM_DL_LEVELS 2 /* # of levels down to create display lists */ |
33 |
|
#define SM_DL_LISTS 42 /* # of qtree nodes in tree at above level: |
57 |
|
}T_DEPTH; |
58 |
|
/**********************************************************************/ |
59 |
|
|
62 |
– |
|
60 |
|
/* |
61 |
|
* smClean(tmflag) : display has been wiped clean |
62 |
|
* int tmflag; |
157 |
|
lcnt[0]++; |
158 |
|
} |
159 |
|
|
163 |
– |
|
160 |
|
QTRAVG * |
161 |
|
qtRender_level(qt,v0,v1,v2,sm,lvl) |
162 |
|
QUADTREE qt; |
206 |
|
else |
207 |
|
{ /* from triangle set */ |
208 |
|
OBJECT *os; |
209 |
< |
int s0, s1, s2; |
210 |
< |
|
209 |
> |
int s0, s1, s2,s_id,t_id; |
210 |
> |
TRI *tri,*t; |
211 |
> |
|
212 |
|
os = qtqueryset(qt); |
213 |
|
for (i = os[0]; i; i--) |
214 |
|
{ |
215 |
< |
if(SM_IS_NTH_T_BASE(sm,os[i])) |
216 |
< |
continue; |
217 |
< |
tri = SM_NTH_TRI(sm,os[i]); |
218 |
< |
if(!T_IS_VALID(tri)) |
219 |
< |
continue; |
220 |
< |
n++; |
221 |
< |
s0 = T_NTH_V(tri,0); |
222 |
< |
s1 = T_NTH_V(tri,1); |
223 |
< |
s2 = T_NTH_V(tri,2); |
224 |
< |
VCOPY(a,SM_NTH_WV(sm,s0)); |
225 |
< |
VCOPY(b,SM_NTH_WV(sm,s1)); |
226 |
< |
VCOPY(c,SM_NTH_WV(sm,s2)); |
227 |
< |
distsum += SM_BG_SAMPLE(sm,s0) ? dev_zmax |
215 |
> |
s_id = os[i]; |
216 |
> |
t_id = SM_NTH_VERT(smMesh,s_id); |
217 |
> |
tri = t = SM_NTH_TRI(smMesh,t_id); |
218 |
> |
do |
219 |
> |
{ |
220 |
> |
if(!SM_IS_NTH_T_BASE(sm,t_id)) |
221 |
> |
{ |
222 |
> |
n++; |
223 |
> |
s0 = T_NTH_V(t,0); |
224 |
> |
s1 = T_NTH_V(t,1); |
225 |
> |
s2 = T_NTH_V(t,2); |
226 |
> |
VCOPY(a,SM_NTH_WV(sm,s0)); |
227 |
> |
VCOPY(b,SM_NTH_WV(sm,s1)); |
228 |
> |
VCOPY(c,SM_NTH_WV(sm,s2)); |
229 |
> |
distsum += SM_BG_SAMPLE(sm,s0) ? dev_zmax |
230 |
|
: sqrt(dist2(a,SM_VIEW_CENTER(sm))); |
231 |
< |
distsum += SM_BG_SAMPLE(sm,s1) ? dev_zmax |
232 |
< |
: sqrt(dist2(b,SM_VIEW_CENTER(sm))); |
233 |
< |
distsum += SM_BG_SAMPLE(sm,s2) ? dev_zmax |
231 |
> |
distsum += SM_BG_SAMPLE(sm,s1) ? dev_zmax |
232 |
> |
: sqrt(dist2(b,SM_VIEW_CENTER(sm))); |
233 |
> |
distsum += SM_BG_SAMPLE(sm,s2) ? dev_zmax |
234 |
|
: sqrt(dist2(c,SM_VIEW_CENTER(sm))); |
235 |
< |
rgbs[0] += SM_NTH_RGB(sm,s0)[0] + SM_NTH_RGB(sm,s1)[0] |
236 |
< |
+ SM_NTH_RGB(sm,s2)[0]; |
237 |
< |
rgbs[1] += SM_NTH_RGB(sm,s0)[1] + SM_NTH_RGB(sm,s1)[1] |
238 |
< |
+ SM_NTH_RGB(sm,s2)[1]; |
239 |
< |
rgbs[2] += SM_NTH_RGB(sm,s0)[2] + SM_NTH_RGB(sm,s1)[2] |
240 |
< |
+ SM_NTH_RGB(sm,s2)[2]; |
235 |
> |
rgbs[0] += SM_NTH_RGB(sm,s0)[0] + SM_NTH_RGB(sm,s1)[0] |
236 |
> |
+ SM_NTH_RGB(sm,s2)[0]; |
237 |
> |
rgbs[1] += SM_NTH_RGB(sm,s0)[1] + SM_NTH_RGB(sm,s1)[1] |
238 |
> |
+ SM_NTH_RGB(sm,s2)[1]; |
239 |
> |
rgbs[2] += SM_NTH_RGB(sm,s0)[2] + SM_NTH_RGB(sm,s1)[2] |
240 |
> |
+ SM_NTH_RGB(sm,s2)[2]; |
241 |
> |
} |
242 |
> |
|
243 |
> |
t_id = smTri_next_ccw_nbr(smMesh,t,s_id); |
244 |
> |
t = SM_NTH_TRI(smMesh,t_id); |
245 |
> |
|
246 |
> |
}while(t != tri); |
247 |
|
} |
248 |
|
n *= 3; |
249 |
|
} |
272 |
|
} |
273 |
|
|
274 |
|
|
275 |
+ |
|
276 |
+ |
|
277 |
|
smRender_approx_stree_level(sm,lvl) |
278 |
|
SM *sm; |
279 |
|
int lvl; |
353 |
|
smRender_approx_stree_level(sm,i); |
354 |
|
} |
355 |
|
|
356 |
+ |
#ifndef LORES |
357 |
+ |
#define GLVERTEX3V(v) glVertex3dv(v) |
358 |
+ |
#else |
359 |
+ |
#define GLVERTEX3V(v) glVertex3fv(v) |
360 |
+ |
#endif |
361 |
+ |
|
362 |
|
#define render_tri(v0,v1,v2,rgb0,rgb1,rgb2) \ |
363 |
< |
{glColor3ub(rgb0[0],rgb0[1],rgb0[2]); glVertex3fv(v0); \ |
364 |
< |
glColor3ub(rgb1[0],rgb1[1],rgb1[2]); glVertex3fv(v1); \ |
365 |
< |
glColor3ub(rgb2[0],rgb2[1],rgb2[2]); glVertex3fv(v2);} |
363 |
> |
{glColor3ub(rgb0[0],rgb0[1],rgb0[2]); GLVERTEX3V(v0); \ |
364 |
> |
glColor3ub(rgb1[0],rgb1[1],rgb1[2]); GLVERTEX3V(v1); \ |
365 |
> |
glColor3ub(rgb2[0],rgb2[1],rgb2[2]); GLVERTEX3V(v2);} |
366 |
|
|
354 |
– |
|
355 |
– |
render_bg_tri(v0,v1,v2,rgb0,rgb1,rgb2,vp,vc,d) |
356 |
– |
float v0[3],v1[3],v2[3]; |
357 |
– |
BYTE rgb0[3],rgb1[3],rgb2[3]; |
358 |
– |
FVECT vp,vc; |
359 |
– |
double d; |
360 |
– |
{ |
361 |
– |
double p[3]; |
362 |
– |
|
363 |
– |
glColor3ub(rgb0[0],rgb0[1],rgb0[2]); |
364 |
– |
VSUB(p,v0,vc); |
365 |
– |
if(dev_zmin >= 0.99) |
366 |
– |
{ |
367 |
– |
p[0] *= d; |
368 |
– |
p[1] *= d; |
369 |
– |
p[2] *= d; |
370 |
– |
} |
371 |
– |
VADD(p,p,vp); |
372 |
– |
glVertex3dv(p); |
373 |
– |
|
374 |
– |
glColor3ub(rgb1[0],rgb1[1],rgb1[2]); |
375 |
– |
VSUB(p,v1,vc); |
376 |
– |
if(dev_zmin >= 0.99) |
377 |
– |
{ |
378 |
– |
p[0] *= d; |
379 |
– |
p[1] *= d; |
380 |
– |
p[2] *= d; |
381 |
– |
} |
382 |
– |
VADD(p,p,vp); |
383 |
– |
glVertex3dv(p); |
384 |
– |
|
385 |
– |
|
386 |
– |
glColor3ub(rgb2[0],rgb2[1],rgb2[2]); |
387 |
– |
VSUB(p,v2,vc); |
388 |
– |
if(dev_zmin >= 0.99) |
389 |
– |
{ |
390 |
– |
p[0] *= d; |
391 |
– |
p[1] *= d; |
392 |
– |
p[2] *= d; |
393 |
– |
VADD(p,p,vp); |
394 |
– |
glVertex3dv(p); |
395 |
– |
} |
396 |
– |
} |
397 |
– |
|
398 |
– |
|
367 |
|
/* |
368 |
|
* render_mixed_tri(v0,v1,v2,rgb0,rgb1,rgb2,b0,b1,b2) |
369 |
< |
* float v0[3],v1[3],v2[3]; : triangle vertex coordinates |
369 |
> |
* SFLOAT v0[3],v1[3],v2[3]; : triangle vertex coordinates |
370 |
|
* BYTE rgb0[3],rgb1[3],rgb2[3]; : vertex RGBs |
371 |
|
* int b0,b1,b2; : background or base vertex flag |
372 |
|
* |
373 |
< |
* render foreground or base vertex color as average of the background |
374 |
< |
* vertex RGBs. |
373 |
> |
* For triangles with one or more base or directional vertices. |
374 |
> |
* render base vertex color as average of the background and foreground |
375 |
> |
* vertex RGBs. The coordinates for a fg vertex are calculated by |
376 |
> |
* subtracting off the current view,normalizing, then scaling to fit |
377 |
> |
* into the current frustum. |
378 |
|
*/ |
379 |
|
render_mixed_tri(v0,v1,v2,rgb0,rgb1,rgb2,vp,vc,bg0,bg1,bg2) |
380 |
< |
float v0[3],v1[3],v2[3]; |
380 |
> |
SFLOAT v0[3],v1[3],v2[3]; |
381 |
|
BYTE rgb0[3],rgb1[3],rgb2[3]; |
382 |
|
FVECT vp,vc; |
383 |
|
int bg0,bg1,bg2; |
384 |
|
{ |
385 |
|
double d,p[3]; |
386 |
< |
int j,cnt,rgb[3],base; |
386 |
> |
int j,cnt,rgb[3]; |
387 |
|
|
388 |
< |
base = bg0==BASE || bg1==BASE || bg2==BASE; |
389 |
< |
|
390 |
< |
if(base) |
388 |
> |
/* Average color from bg vertices */ |
389 |
> |
cnt = 0; |
390 |
> |
if(bg0 == BASE || bg1==BASE || bg2 == BASE) |
391 |
|
{ |
421 |
– |
cnt = 0; |
392 |
|
rgb[0] = rgb[1] = rgb[2] = 0; |
393 |
|
if(bg0 != BASE) |
394 |
< |
{ |
395 |
< |
IADDV3(rgb,rgb0); |
396 |
< |
cnt++; |
397 |
< |
} |
398 |
< |
if(bg1 !=BASE) |
399 |
< |
{ |
400 |
< |
IADDV3(rgb,rgb1); |
401 |
< |
cnt++; |
402 |
< |
} |
394 |
> |
{ |
395 |
> |
IADDV3(rgb,rgb0); |
396 |
> |
cnt++; |
397 |
> |
} |
398 |
> |
if(bg1 != BASE) |
399 |
> |
{ |
400 |
> |
IADDV3(rgb,rgb1); |
401 |
> |
cnt++; |
402 |
> |
} |
403 |
|
if(bg2 != BASE) |
404 |
< |
{ |
405 |
< |
IADDV3(rgb,rgb2); |
406 |
< |
cnt++; |
407 |
< |
} |
404 |
> |
{ |
405 |
> |
IADDV3(rgb,rgb2); |
406 |
> |
cnt++; |
407 |
> |
} |
408 |
|
IDIVV3(rgb,cnt); |
409 |
|
} |
410 |
< |
|
411 |
< |
if(bg0== BASE) |
442 |
< |
glColor3ub(rgb[0],rgb[1],rgb[2]); |
410 |
> |
if(bg0 == BASE) |
411 |
> |
glColor3i(rgb[0],rgb[1],rgb[2]); |
412 |
|
else |
413 |
|
glColor3ub(rgb0[0],rgb0[1],rgb0[2]); |
414 |
|
|
420 |
|
glVertex3dv(p); |
421 |
|
} |
422 |
|
else |
423 |
< |
glVertex3fv(v0); |
423 |
> |
GLVERTEX3V(v0); |
424 |
|
|
425 |
< |
if(bg1== BASE) |
426 |
< |
glColor3ub(rgb[0],rgb[1],rgb[2]); |
425 |
> |
if(bg1 == BASE) |
426 |
> |
glColor3i(rgb[0],rgb[1],rgb[2]); |
427 |
|
else |
428 |
|
glColor3ub(rgb1[0],rgb1[1],rgb1[2]); |
429 |
|
|
435 |
|
glVertex3dv(p); |
436 |
|
} |
437 |
|
else |
438 |
< |
glVertex3fv(v1); |
438 |
> |
GLVERTEX3V(v1); |
439 |
|
|
440 |
< |
if(bg2== BASE) |
441 |
< |
glColor3ub(rgb[0],rgb[1],rgb[2]); |
440 |
> |
if(bg2 == BASE) |
441 |
> |
glColor3i(rgb[0],rgb[1],rgb[2]); |
442 |
|
else |
443 |
|
glColor3ub(rgb2[0],rgb2[1],rgb2[2]); |
444 |
|
|
450 |
|
glVertex3dv(p); |
451 |
|
} |
452 |
|
else |
453 |
< |
glVertex3fv(v2); |
453 |
> |
GLVERTEX3V(v2); |
454 |
|
} |
455 |
|
|
456 |
|
/* |
459 |
|
* FVECT vp; : current viewpoint |
460 |
|
* int4 *t_flag,*bg_flag; : triangle flags: t_flag is generic, |
461 |
|
* and bg_flag indicates if background tri; |
462 |
< |
* float (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
462 |
> |
* SFLOAT (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
463 |
|
* |
464 |
< |
* Sequentially gos through triangle list and renders all valid tris who |
464 |
> |
* Sequentially traverses triangle list and renders all valid tris who |
465 |
|
* have t_flag set, and bg_flag set. |
466 |
|
*/ |
467 |
|
|
469 |
|
SM *sm; |
470 |
|
FVECT vp; |
471 |
|
int4 *t_flag,*bg_flag; |
472 |
< |
float (*wp)[3]; |
472 |
> |
SFLOAT (*wp)[3]; |
473 |
|
BYTE (*rgb)[3]; |
474 |
|
{ |
475 |
|
double d; |
511 |
|
rgb[v2_id]) |
512 |
|
else |
513 |
|
render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
514 |
< |
rgb[v1_id],rgb[v2_id],vp,SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
514 |
> |
rgb[v1_id],rgb[v2_id],vp,SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
515 |
|
} |
516 |
|
glEnd(); |
517 |
|
|
519 |
|
|
520 |
|
} |
521 |
|
/* |
522 |
+ |
* smRender_new_bg_tris(sm,vp,t_flag,bg_flag,wp,rgb) |
523 |
+ |
* SM *sm; : mesh |
524 |
+ |
* FVECT vp; : current viewpoint |
525 |
+ |
* int4 *t_flag,*bg_flag; : triangle flags: t_flag is generic, |
526 |
+ |
* and bg_flag indicates if background tri; |
527 |
+ |
* SFLOAT (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
528 |
+ |
* |
529 |
+ |
* Sequentially traverses triangle list and renders all valid tris who |
530 |
+ |
* have t_flag set, and bg_flag set. |
531 |
+ |
*/ |
532 |
+ |
|
533 |
+ |
smRender_new_bg_tris(sm,vp,new_flag,active_flag,bg_flag,wp,rgb) |
534 |
+ |
SM *sm; |
535 |
+ |
FVECT vp; |
536 |
+ |
int4 *new_flag,*active_flag,*bg_flag; |
537 |
+ |
SFLOAT (*wp)[3]; |
538 |
+ |
BYTE (*rgb)[3]; |
539 |
+ |
{ |
540 |
+ |
double d; |
541 |
+ |
int v0_id,v1_id,v2_id; |
542 |
+ |
int i,n,bg0,bg1,bg2; |
543 |
+ |
TRI *tri; |
544 |
+ |
|
545 |
+ |
glMatrixMode(GL_MODELVIEW); |
546 |
+ |
|
547 |
+ |
glPushMatrix(); |
548 |
+ |
glTranslated(vp[0],vp[1],vp[2]); |
549 |
+ |
/* The points are a distance of 1 away from the origin: if necessary scale |
550 |
+ |
so that they fit in frustum and are therefore not clipped away |
551 |
+ |
*/ |
552 |
+ |
if(dev_zmin >= 0.99) |
553 |
+ |
{ |
554 |
+ |
d = (dev_zmin+dev_zmax)/2.0; |
555 |
+ |
glScaled(d,d,d); |
556 |
+ |
} |
557 |
+ |
/* move relative to the new view */ |
558 |
+ |
/* move points to unit sphere at origin */ |
559 |
+ |
glTranslated(-SM_VIEW_CENTER(sm)[0],-SM_VIEW_CENTER(sm)[1], |
560 |
+ |
-SM_VIEW_CENTER(sm)[2]); |
561 |
+ |
glBegin(GL_TRIANGLES); |
562 |
+ |
for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;) |
563 |
+ |
if(new_flag[n] & active_flag[n] & bg_flag[n]) |
564 |
+ |
for(i=0; i < 32; i++) |
565 |
+ |
if(new_flag[n] & active_flag[n] & bg_flag[n] & (1L << i)) |
566 |
+ |
{ |
567 |
+ |
tri = SM_NTH_TRI(sm,(n<<5)+i); |
568 |
+ |
v0_id = T_NTH_V(tri,0); |
569 |
+ |
v1_id = T_NTH_V(tri,1); |
570 |
+ |
v2_id = T_NTH_V(tri,2); |
571 |
+ |
bg0 = SM_DIR_ID(sm,v0_id)?DIR:SM_BASE_ID(sm,v0_id)?BASE:0; |
572 |
+ |
bg1 = SM_DIR_ID(sm,v1_id)?DIR:SM_BASE_ID(sm,v1_id)?BASE:0; |
573 |
+ |
bg2 = SM_DIR_ID(sm,v2_id)?DIR:SM_BASE_ID(sm,v2_id)?BASE:0; |
574 |
+ |
if(bg0==DIR && bg1==DIR && bg2==DIR) |
575 |
+ |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
576 |
+ |
rgb[v2_id]) |
577 |
+ |
else |
578 |
+ |
render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
579 |
+ |
rgb[v1_id],rgb[v2_id],vp,SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
580 |
+ |
} |
581 |
+ |
glEnd(); |
582 |
+ |
|
583 |
+ |
glPopMatrix(); |
584 |
+ |
|
585 |
+ |
} |
586 |
+ |
|
587 |
+ |
/* |
588 |
|
* render_base_tri(v0,v1,v2,rgb0,rgb1,rgb2,vp,b0,b1,b2) |
589 |
< |
* float v0[3],v1[3],v2[3]; : triangle vertex coordinates |
589 |
> |
* SFLOAT v0[3],v1[3],v2[3]; : triangle vertex coordinates |
590 |
|
* BYTE rgb0[3],rgb1[3],rgb2[3]; : vertex RGBs |
591 |
|
* FVECT vp; : current viewpoint |
592 |
|
* int b0,b1,b2; : vertex base flag |
596 |
|
* the average distance to the non-base vertices |
597 |
|
*/ |
598 |
|
render_base_tri(v0,v1,v2,rgb0,rgb1,rgb2,vp,b0,b1,b2) |
599 |
< |
float v0[3],v1[3],v2[3]; |
599 |
> |
SFLOAT v0[3],v1[3],v2[3]; |
600 |
|
BYTE rgb0[3],rgb1[3],rgb2[3]; |
601 |
|
FVECT vp; |
602 |
|
int b0,b1,b2; |
647 |
|
else |
648 |
|
{ |
649 |
|
glColor3ub(rgb0[0],rgb0[1],rgb0[2]); |
650 |
< |
glVertex3fv(v0); |
650 |
> |
GLVERTEX3V(v0); |
651 |
|
} |
652 |
|
if(b1) |
653 |
|
{ |
660 |
|
else |
661 |
|
{ |
662 |
|
glColor3ub(rgb1[0],rgb1[1],rgb1[2]); |
663 |
< |
glVertex3fv(v1); |
663 |
> |
GLVERTEX3V(v1); |
664 |
|
} |
665 |
|
if(b2) |
666 |
|
{ |
673 |
|
else |
674 |
|
{ |
675 |
|
glColor3ub(rgb2[0],rgb2[1],rgb2[2]); |
676 |
< |
glVertex3fv(v2); |
676 |
> |
GLVERTEX3V(v2); |
677 |
|
} |
678 |
|
} |
679 |
|
/* |
682 |
|
* FVECT vp; : current viewpoint |
683 |
|
* int4 *t_flag,*bg_flag; : triangle flags: t_flag is generic,bg_flag |
684 |
|
* indicates if background tri; |
685 |
< |
* float (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
685 |
> |
* SFLOAT (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
686 |
|
* |
687 |
|
* Sequentially gos through triangle list and renders all valid tris who |
688 |
|
* have t_flag set, and NOT bg_flag set. |
691 |
|
SM *sm; |
692 |
|
FVECT vp; |
693 |
|
int4 *t_flag,*bg_flag; |
694 |
< |
float (*wp)[3]; |
694 |
> |
SFLOAT (*wp)[3]; |
695 |
|
BYTE (*rgb)[3]; |
696 |
|
{ |
697 |
|
TRI *tri; |
717 |
|
else |
718 |
|
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
719 |
|
rgb[v2_id]) |
720 |
+ |
|
721 |
|
} |
722 |
|
glEnd(); |
723 |
|
|
724 |
|
} |
725 |
|
|
726 |
+ |
/* |
727 |
+ |
* smRender_fg_tris(sm,vp,t_flag,bg_flag,wp,rgb) |
728 |
+ |
* SM *sm; : mesh |
729 |
+ |
* FVECT vp; : current viewpoint |
730 |
+ |
* int4 *t_flag,*bg_flag; : triangle flags: t_flag is generic,bg_flag |
731 |
+ |
* indicates if background tri; |
732 |
+ |
* SFLOAT (*wp)[3];BYTE (*rgb)[3]; : arrays of sample points and RGB colors |
733 |
+ |
* |
734 |
+ |
* Sequentially gos through triangle list and renders all valid tris who |
735 |
+ |
* have t_flag set, and NOT bg_flag set. |
736 |
+ |
*/ |
737 |
+ |
smRender_new_fg_tris(sm,vp,new_flag,active_flag,bg_flag,wp,rgb) |
738 |
+ |
SM *sm; |
739 |
+ |
FVECT vp; |
740 |
+ |
int4 *new_flag,*active_flag,*bg_flag; |
741 |
+ |
SFLOAT (*wp)[3]; |
742 |
+ |
BYTE (*rgb)[3]; |
743 |
+ |
{ |
744 |
+ |
TRI *tri; |
745 |
+ |
int i,n,b0,b1,b2; |
746 |
+ |
int v0_id,v1_id,v2_id; |
747 |
+ |
|
748 |
+ |
glBegin(GL_TRIANGLES); |
749 |
+ |
for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;) |
750 |
+ |
if(new_flag[n] & active_flag[n]) |
751 |
+ |
for(i=0; i < 32; i++) |
752 |
+ |
if(new_flag[n] & active_flag[n] & (1L << i) & ~bg_flag[n]) |
753 |
+ |
{ |
754 |
+ |
tri = SM_NTH_TRI(sm,(n<<5)+i); |
755 |
+ |
v0_id = T_NTH_V(tri,0); |
756 |
+ |
v1_id = T_NTH_V(tri,1); |
757 |
+ |
v2_id = T_NTH_V(tri,2); |
758 |
+ |
b0 = SM_BASE_ID(sm,v0_id); |
759 |
+ |
b1 = SM_BASE_ID(sm,v1_id); |
760 |
+ |
b2 = SM_BASE_ID(sm,v2_id); |
761 |
+ |
if(b0 || b1 || b2) |
762 |
+ |
render_base_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
763 |
+ |
rgb[v1_id],rgb[v2_id],SM_VIEW_CENTER(sm),b0,b1,b2); |
764 |
+ |
else |
765 |
+ |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
766 |
+ |
rgb[v2_id]) |
767 |
|
|
768 |
+ |
} |
769 |
+ |
glEnd(); |
770 |
+ |
|
771 |
+ |
} |
772 |
+ |
|
773 |
+ |
|
774 |
|
int |
775 |
|
compare_tri_depths(T_DEPTH *td1,T_DEPTH *td2) |
776 |
|
{ |
782 |
|
if(d < 0.0) |
783 |
|
return(-1); |
784 |
|
return(0); |
702 |
– |
|
785 |
|
} |
786 |
|
|
705 |
– |
#ifdef DEBUG |
706 |
– |
#define freebuf(b) tempbuf(-1) |
707 |
– |
#endif |
787 |
|
|
709 |
– |
char * |
710 |
– |
tempbuf(len) /* get a temporary buffer */ |
711 |
– |
unsigned len; |
712 |
– |
{ |
713 |
– |
extern char *malloc(), *realloc(); |
714 |
– |
static char *tempbuf = NULL; |
715 |
– |
static unsigned tempbuflen = 0; |
716 |
– |
|
717 |
– |
#ifdef DEBUG |
718 |
– |
static int in_use=FALSE; |
719 |
– |
|
720 |
– |
if(len == -1) |
721 |
– |
{ |
722 |
– |
in_use = FALSE; |
723 |
– |
return(NULL); |
724 |
– |
} |
725 |
– |
if(in_use) |
726 |
– |
{ |
727 |
– |
eputs("Buffer in use:cannot allocate:tempbuf()\n"); |
728 |
– |
return(NULL); |
729 |
– |
} |
730 |
– |
#endif |
731 |
– |
if (len > tempbuflen) { |
732 |
– |
if (tempbuflen > 0) |
733 |
– |
tempbuf = realloc(tempbuf, len); |
734 |
– |
else |
735 |
– |
tempbuf = malloc(len); |
736 |
– |
tempbuflen = tempbuf==NULL ? 0 : len; |
737 |
– |
} |
738 |
– |
#ifdef DEBUG |
739 |
– |
in_use = TRUE; |
740 |
– |
#endif |
741 |
– |
return(tempbuf); |
742 |
– |
} |
743 |
– |
|
788 |
|
/* |
789 |
|
* smOrder_new_tris(sm,vp,td) |
790 |
|
* SM *sm; : mesh |
794 |
|
* Creates list of all new tris, with their distance from the current |
795 |
|
* viewpoint, and sorts the list based on this distance |
796 |
|
*/ |
797 |
< |
smOrder_new_tris(sm,vp,td) |
797 |
> |
T_DEPTH |
798 |
> |
*smOrder_new_tris(sm,vp) |
799 |
|
SM *sm; |
800 |
|
FVECT vp; |
756 |
– |
T_DEPTH *td; |
801 |
|
{ |
802 |
< |
int n,i,j,tcnt,v; |
802 |
> |
T_DEPTH *td; |
803 |
> |
int n,i,j,tcnt,v,size; |
804 |
|
TRI *tri; |
805 |
|
double d,min_d; |
806 |
|
FVECT diff; |
807 |
< |
int4 *new_flag,*bg_flag; |
807 |
> |
int4 *new_flag,*bg_flag,*active_flag; |
808 |
> |
|
809 |
> |
td = (T_DEPTH *)tempbuf(MAX_NEW_TRIS*sizeof(T_DEPTH),FALSE); |
810 |
> |
size = MAX_NEW_TRIS; |
811 |
|
|
812 |
|
tcnt=0; |
813 |
|
new_flag = SM_NTH_FLAGS(sm,T_NEW_FLAG); |
814 |
|
bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG); |
815 |
+ |
active_flag = SM_NTH_FLAGS(sm,T_ACTIVE_FLAG); |
816 |
|
for(n=((SM_NUM_TRI(sm)+31)>>5) +1; --n;) |
817 |
< |
if(new_flag[n] & ~bg_flag[n]) |
817 |
> |
if(active_flag[n] & new_flag[n] & ~bg_flag[n]) |
818 |
|
for(i=0; i < 32; i++) |
819 |
< |
if(new_flag[n] & (1L << i) & ~bg_flag[n]) |
819 |
> |
if(active_flag[n] & new_flag[n] & (1L << i) & ~bg_flag[n]) |
820 |
|
{ |
821 |
|
tri = SM_NTH_TRI(sm,(n<<5)+i); |
822 |
+ |
if(tcnt+1 >= size) |
823 |
+ |
{ |
824 |
+ |
size += 100; |
825 |
+ |
td = (T_DEPTH *)tempbuf(size*sizeof(T_DEPTH),TRUE); |
826 |
+ |
} |
827 |
|
td[tcnt].tri = (n << 5)+i; |
828 |
|
min_d = -1; |
829 |
|
for(j=0;j < 3;j++) |
839 |
|
td[tcnt].tri = -1; |
840 |
|
if(tcnt) |
841 |
|
qsort((void *)td,tcnt,sizeof(T_DEPTH),compare_tri_depths); |
842 |
+ |
return(td); |
843 |
|
} |
844 |
|
|
845 |
|
/* |
883 |
|
{ |
884 |
|
int i,n,v0_id,v1_id,v2_id,b0,b1,b2; |
885 |
|
TRI *tri; |
886 |
< |
float (*wp)[3]; |
886 |
> |
SFLOAT (*wp)[3]; |
887 |
|
BYTE (*rgb)[3]; |
888 |
< |
int4 *new_flag,*bg_flag; |
888 |
> |
int4 *new_flag,*bg_flag,*active_flag; |
889 |
|
T_DEPTH *td = NULL; |
890 |
|
|
836 |
– |
smUpdate_tm(sm); |
891 |
|
|
892 |
|
/* For all of the NEW triangles (since last update): assume |
893 |
|
ACTIVE. Go through and sort on depth value (from vp). Turn |
894 |
|
Depth Buffer test off and render back-front |
895 |
|
*/ |
896 |
+ |
|
897 |
+ |
/* Must depth sort if view points do not coincide */ |
898 |
|
if(!EQUAL_VEC3(SM_VIEW_CENTER(sm),vp)) |
899 |
< |
{ |
844 |
< |
/* Must depth sort if view points do not coincide */ |
845 |
< |
td = (T_DEPTH *)tempbuf(smNew_tri_cnt*sizeof(T_DEPTH)); |
846 |
< |
if(td) |
847 |
< |
smOrder_new_tris(sm,vp,td); |
848 |
< |
#ifdef DEBUG |
849 |
< |
else |
850 |
< |
eputs("Cant create list:wont depth sort:smUpdate_incremental\n"); |
851 |
< |
#endif |
852 |
< |
} |
899 |
> |
td = smOrder_new_tris(sm,vp); |
900 |
|
wp = SM_WP(sm); |
901 |
|
rgb =SM_RGB(sm); |
902 |
|
new_flag = SM_NTH_FLAGS(sm,T_NEW_FLAG); |
903 |
+ |
active_flag = SM_NTH_FLAGS(sm,T_ACTIVE_FLAG); |
904 |
|
bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG); |
905 |
|
/* Turn Depth Test off -- using Painter's algorithm */ |
906 |
|
glPushAttrib(GL_DEPTH_BUFFER_BIT); |
907 |
|
glDepthFunc(GL_ALWAYS); |
908 |
|
|
909 |
< |
smRender_bg_tris(sm,vp,new_flag,bg_flag,wp,rgb); |
909 |
> |
smRender_new_bg_tris(sm,vp,new_flag,active_flag,bg_flag,wp,rgb); |
910 |
|
if(!td) |
911 |
< |
smRender_fg_tris(sm,vp,new_flag,bg_flag,wp,rgb); |
911 |
> |
smRender_new_fg_tris(sm,vp,new_flag,active_flag,bg_flag,wp,rgb); |
912 |
|
else |
913 |
|
{ |
914 |
|
glBegin(GL_TRIANGLES); |
943 |
|
* SM *sm; : mesh |
944 |
|
* QUADTREE qt; : quadtree base node |
945 |
|
* FVECT vp; : current viewpoint |
946 |
< |
* float (*wp)[3]; : array of sample points |
946 |
> |
* SFLOAT (*wp)[3]; : array of sample points |
947 |
|
* BYTE (*rgb)[3]; : array of RGB values for samples |
948 |
|
* int i,level_i,level,max_level,leaf_cnt; |
949 |
|
* : variables to keep track of where |
965 |
|
SM *sm; |
966 |
|
QUADTREE qt; |
967 |
|
FVECT vp; |
968 |
< |
float (*wp)[3]; |
968 |
> |
SFLOAT (*wp)[3]; |
969 |
|
BYTE (*rgb)[3]; |
970 |
|
int i,level_i,level,max_level,leaf_cnt; |
971 |
|
int which; |
1019 |
|
* SM *sm; : mesh |
1020 |
|
* QUADTREE qt; : quadtree base node |
1021 |
|
* FVECT vp; : current viewpoint |
1022 |
< |
* float (*wp)[3] : array of sample points |
1022 |
> |
* SFLOAT (*wp)[3] : array of sample points |
1023 |
|
* BYTE (*rgb)[3] : array of RGB values for samples |
1024 |
|
* int which; : flag indicates whether to render fg or bg tris |
1025 |
|
* int cull; : if true, only traverse active (flagged) nodes |
1029 |
|
SM *sm; |
1030 |
|
QUADTREE qt; |
1031 |
|
FVECT vp; |
1032 |
< |
float (*wp)[3]; |
1032 |
> |
SFLOAT (*wp)[3]; |
1033 |
|
BYTE (*rgb)[3]; |
1034 |
|
int which,cull; |
1035 |
|
{ |
1040 |
|
|
1041 |
|
if(QT_IS_LEAF(qt)) |
1042 |
|
{ |
1043 |
< |
TRI *t; |
1043 |
> |
TRI *t,*tri; |
1044 |
|
OBJECT *optr; |
1045 |
< |
int t_id,v0_id,v1_id,v2_id,bg0,bg1,bg2; |
1045 |
> |
int v0_id,v1_id,v2_id,bg0,bg1,bg2; |
1046 |
> |
int t_id,s_id; |
1047 |
|
|
1048 |
|
if(cull && !QT_LEAF_IS_FLAG(qt)) |
1049 |
|
return; |
1050 |
|
|
1051 |
|
optr = qtqueryset(qt); |
1052 |
< |
for (i = QT_SET_CNT(optr),optr = QT_SET_PTR(optr);i > 0; i--) |
1052 |
> |
for (i = QT_SET_CNT(optr);i > 0; i--) |
1053 |
|
{ |
1054 |
< |
t_id = QT_SET_NEXT_ELEM(optr); |
1055 |
< |
t = SM_NTH_TRI(sm,t_id); |
1056 |
< |
if(!T_IS_VALID(t) || (cull &&!SM_IS_NTH_T_ACTIVE(sm,t_id)) || |
1057 |
< |
SM_IS_NTH_T_NEW(sm,t_id)) |
1009 |
< |
continue; |
1010 |
< |
|
1011 |
< |
bg0 = SM_IS_NTH_T_BG(sm,t_id); |
1012 |
< |
if((which== SM_RENDER_FG && bg0) || (which== SM_RENDER_BG && !bg0)) |
1013 |
< |
continue; |
1014 |
< |
|
1015 |
< |
v0_id = T_NTH_V(t,0); |
1016 |
< |
v1_id = T_NTH_V(t,1); |
1017 |
< |
v2_id = T_NTH_V(t,2); |
1018 |
< |
if(bg0) |
1054 |
> |
s_id = QT_SET_NEXT_ELEM(optr); |
1055 |
> |
t_id = SM_NTH_VERT(smMesh,s_id); |
1056 |
> |
tri = t = SM_NTH_TRI(smMesh,t_id); |
1057 |
> |
do |
1058 |
|
{ |
1059 |
< |
bg0 = SM_DIR_ID(sm,v0_id)?DIR:SM_BASE_ID(sm,v0_id)?BASE:0; |
1060 |
< |
bg1 = SM_DIR_ID(sm,v1_id)?DIR:SM_BASE_ID(sm,v1_id)?BASE:0; |
1061 |
< |
bg2 = SM_DIR_ID(sm,v2_id)?DIR:SM_BASE_ID(sm,v2_id)?BASE:0; |
1062 |
< |
SM_SET_NTH_T_NEW(sm,t_id); |
1063 |
< |
if(bg0==DIR && bg1==DIR && bg2==DIR) |
1064 |
< |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
1065 |
< |
rgb[v2_id]) |
1066 |
< |
else |
1067 |
< |
render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
1068 |
< |
rgb[v1_id],rgb[v2_id],vp,SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
1069 |
< |
} |
1070 |
< |
else |
1071 |
< |
{ |
1072 |
< |
SM_SET_NTH_T_NEW(sm,t_id); |
1073 |
< |
bg0 = SM_BASE_ID(sm,v0_id); |
1074 |
< |
bg1 = SM_BASE_ID(sm,v1_id); |
1075 |
< |
bg2 = SM_BASE_ID(sm,v2_id); |
1076 |
< |
if(bg0 || bg1 || bg2) |
1077 |
< |
render_base_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
1078 |
< |
rgb[v1_id],rgb[v2_id],SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
1079 |
< |
else |
1080 |
< |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
1081 |
< |
rgb[v2_id]) |
1082 |
< |
} |
1059 |
> |
if((!cull || SM_IS_NTH_T_ACTIVE(sm,t_id)) && !SM_IS_NTH_T_NEW(sm,t_id)) |
1060 |
> |
{ |
1061 |
> |
bg0 = SM_IS_NTH_T_BG(sm,t_id); |
1062 |
> |
if((which == SM_RENDER_FG && !bg0) || (which== SM_RENDER_BG && bg0)) |
1063 |
> |
{ |
1064 |
> |
v0_id = T_NTH_V(t,0); |
1065 |
> |
v1_id = T_NTH_V(t,1); |
1066 |
> |
v2_id = T_NTH_V(t,2); |
1067 |
> |
if(bg0) |
1068 |
> |
{ |
1069 |
> |
bg0 = SM_DIR_ID(sm,v0_id)?DIR:SM_BASE_ID(sm,v0_id)?BASE:0; |
1070 |
> |
bg1 = SM_DIR_ID(sm,v1_id)?DIR:SM_BASE_ID(sm,v1_id)?BASE:0; |
1071 |
> |
bg2 = SM_DIR_ID(sm,v2_id)?DIR:SM_BASE_ID(sm,v2_id)?BASE:0; |
1072 |
> |
SM_SET_NTH_T_NEW(sm,t_id); |
1073 |
> |
if(bg0==DIR && bg1==DIR && bg2==DIR) |
1074 |
> |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
1075 |
> |
rgb[v2_id]) |
1076 |
> |
else |
1077 |
> |
render_mixed_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
1078 |
> |
rgb[v1_id],rgb[v2_id],vp,SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
1079 |
> |
} |
1080 |
> |
else |
1081 |
> |
{ |
1082 |
> |
SM_SET_NTH_T_NEW(sm,t_id); |
1083 |
> |
bg0 = SM_BASE_ID(sm,v0_id); |
1084 |
> |
bg1 = SM_BASE_ID(sm,v1_id); |
1085 |
> |
bg2 = SM_BASE_ID(sm,v2_id); |
1086 |
> |
if(bg0 || bg1 || bg2) |
1087 |
> |
render_base_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id], |
1088 |
> |
rgb[v1_id],rgb[v2_id],SM_VIEW_CENTER(sm),bg0,bg1,bg2); |
1089 |
> |
else |
1090 |
> |
render_tri(wp[v0_id],wp[v1_id],wp[v2_id],rgb[v0_id],rgb[v1_id], |
1091 |
> |
rgb[v2_id]) |
1092 |
> |
} |
1093 |
> |
} |
1094 |
> |
} |
1095 |
> |
t_id = smTri_next_ccw_nbr(smMesh,t,s_id); |
1096 |
> |
t = SM_NTH_TRI(smMesh,t_id); |
1097 |
> |
}while(t!=tri); |
1098 |
|
} |
1099 |
|
} |
1100 |
|
else |
1103 |
|
smRender_qtree(sm,QT_NTH_CHILD(qt,i),vp,wp,rgb,which,cull); |
1104 |
|
} |
1105 |
|
|
1106 |
+ |
|
1107 |
|
/* |
1108 |
|
* smRender_mesh(sm,view,cull) : Render mesh Triangles |
1109 |
|
* SM *sm; : mesh |
1120 |
|
VIEW *view; |
1121 |
|
int cull; |
1122 |
|
{ |
1123 |
< |
float (*wp)[3]; |
1123 |
> |
SFLOAT (*wp)[3]; |
1124 |
|
BYTE (*rgb)[3]; |
1125 |
|
int i; |
1126 |
|
STREE *st= SM_LOCATOR(sm); |
1127 |
|
|
1073 |
– |
smUpdate_tm(sm); |
1128 |
|
|
1129 |
|
wp = SM_WP(sm); |
1130 |
|
rgb =SM_RGB(sm); |
1131 |
|
|
1132 |
|
smClear_flags(sm,T_NEW_FLAG); |
1133 |
|
|
1134 |
+ |
|
1135 |
|
if(cull) |
1136 |
|
smCull(sm,view,SM_ALL_LEVELS); |
1137 |
|
|
1185 |
|
SM *sm; |
1186 |
|
VIEW *view; |
1187 |
|
{ |
1188 |
< |
float (*wp)[3]; |
1188 |
> |
SFLOAT (*wp)[3]; |
1189 |
|
BYTE (*rgb)[3]; |
1190 |
|
STREE *st; |
1191 |
|
int i; |
1204 |
|
|
1205 |
|
return; |
1206 |
|
} |
1207 |
+ |
smClear_flags(sm,T_NEW_FLAG); |
1208 |
+ |
|
1209 |
|
smCull(sm,view,SM_DL_LEVELS); |
1210 |
|
|
1211 |
|
st = SM_LOCATOR(sm); |
1265 |
|
int render_flag; |
1266 |
|
{ |
1267 |
|
int4 *active_flag,*bg_flag; |
1268 |
< |
float (*wp)[3]; |
1268 |
> |
SFLOAT (*wp)[3]; |
1269 |
|
BYTE (*rgb)[3]; |
1270 |
|
|
1271 |
|
wp = SM_WP(sm); |
1272 |
< |
rgb =SM_RGB(sm); |
1272 |
> |
rgb = SM_RGB(sm); |
1273 |
|
active_flag = SM_NTH_FLAGS(sm,T_ACTIVE_FLAG); |
1274 |
|
bg_flag = SM_NTH_FLAGS(sm,T_BG_FLAG); |
1275 |
|
|
1423 |
|
VIEW *view; |
1424 |
|
int qual; |
1425 |
|
{ |
1369 |
– |
|
1370 |
– |
/* Recompute tone mapping if specified */ |
1371 |
– |
if( qual >= MAXQUALITY && smCompute_mapping) |
1372 |
– |
smUpdate_tm(sm); |
1373 |
– |
|
1426 |
|
/* Unless quality > MAXQUALITY, render using display lists */ |
1427 |
|
if(qual <= MAXQUALITY) |
1428 |
|
{ |
1429 |
|
/* If quality above threshold: render mesh*/ |
1430 |
< |
if(qual > (MAXQUALITY*2/4)) |
1430 |
> |
if(qual > (MAXQUALITY*2/4) ) |
1431 |
|
/* render stree using display lists */ |
1432 |
|
smRender_mesh_dl(sm,view); |
1433 |
|
else |
1434 |
+ |
{ |
1435 |
|
/* If quality below threshold, use approximate rendering */ |
1436 |
|
smRender_approx(sm,qual,view); |
1437 |
+ |
} |
1438 |
|
} |
1439 |
|
else |
1440 |
< |
/* render stree without display lists */ |
1440 |
> |
{ |
1441 |
> |
/* render stree without display lists */ |
1442 |
|
smRender_mesh(sm,view,TRUE); |
1443 |
+ |
} |
1444 |
|
} |
1445 |
|
|
1446 |
|
|
1467 |
|
/* Is viewer MOVING?*/ |
1468 |
|
if(qual < MAXQUALITY) |
1469 |
|
{ |
1470 |
+ |
if(smIncremental) |
1471 |
+ |
smUpdate_tm(smMesh); |
1472 |
+ |
smIncremental = FALSE; |
1473 |
|
/* Render mesh using display lists */ |
1474 |
|
smRender(smMesh,view,qual); |
1475 |
|
return; |
1476 |
|
} |
1418 |
– |
|
1477 |
|
/* Viewer is STATIONARY */ |
1420 |
– |
|
1478 |
|
/* Has view moved epsilon from canonical view? (epsilon= percentage |
1479 |
|
(SM_VIEW_FRAC) of running average of the distance of the sample points |
1480 |
|
from the canonical view */ |
1481 |
|
if(DIST(view->vp,SM_VIEW_CENTER(smMesh)) > SM_ALLOWED_VIEW_CHANGE(smMesh)) |
1482 |
|
{ |
1483 |
|
/* Must rebuild mesh with current view as new canonical view */ |
1484 |
< |
smRebuild_mesh(smMesh,view); |
1484 |
> |
smRebuild(smMesh,view); |
1485 |
|
/* Existing display lists and tonemapping are no longer valid */ |
1486 |
|
clear_display_lists(); |
1487 |
< |
smCompute_mapping = TRUE; |
1487 |
> |
smCompute_mapping = FALSE; |
1488 |
> |
smUpdate_tm(smMesh); |
1489 |
|
/* Render all the triangles in the new mesh */ |
1490 |
|
smRender(smMesh,view,qual+1); |
1491 |
|
} |
1493 |
|
/* Has a complete redraw been requested ?*/ |
1494 |
|
if(smClean_notify) |
1495 |
|
{ |
1496 |
+ |
if(smIncremental) |
1497 |
+ |
smUpdate_tm(smMesh); |
1498 |
|
smIncremental = FALSE; |
1499 |
|
smRender(smMesh,view,qual); |
1500 |
|
} |
1501 |
|
else |
1502 |
|
{ |
1503 |
< |
/* Viewer fixed and receiving new samples for the same view */ |
1444 |
< |
if(!smNew_tri_cnt) |
1445 |
< |
return; |
1446 |
< |
|
1503 |
> |
smUpdate_tm(smMesh); |
1504 |
|
/* If number of new triangles relatively small: do incremental update */ |
1505 |
< |
if(smNew_tri_cnt < SM_SAMPLE_TRIS(smMesh)*SM_INC_PERCENT) |
1506 |
< |
{ |
1507 |
< |
/* Mark Existing display lists in frustum invalid */ |
1508 |
< |
if(!smIncremental) |
1509 |
< |
{ |
1510 |
< |
smInvalidate_view(smMesh,view); |
1511 |
< |
smIncremental = TRUE; |
1455 |
< |
} |
1456 |
< |
smRender_inc(smMesh,view->vp); |
1457 |
< |
} |
1458 |
< |
else |
1459 |
< |
/* Otherwise render all of the active triangles */ |
1460 |
< |
smRender(smMesh,view,qual+1); |
1505 |
> |
/* Mark Existing display lists in frustum invalid */ |
1506 |
> |
if(!smIncremental) |
1507 |
> |
{ |
1508 |
> |
smInvalidate_view(smMesh,view); |
1509 |
> |
smIncremental = TRUE; |
1510 |
> |
} |
1511 |
> |
smRender_inc(smMesh,view->vp); |
1512 |
|
} |
1513 |
|
/* This is our final update iff qual==MAXQUALITY and view==&odev.v */ |
1514 |
|
if( (qual >= MAXQUALITY) && (view == &(odev.v))) |
1515 |
|
{ |
1516 |
|
/* reset rendering flags */ |
1517 |
|
smClean_notify = FALSE; |
1518 |
< |
smNew_tri_cnt = 0; |
1519 |
< |
smClear_flags(smMesh,T_NEW_FLAG); |
1518 |
> |
if(smIncremental) |
1519 |
> |
smClear_flags(smMesh,T_NEW_FLAG); |
1520 |
|
qtCache_init(0); |
1521 |
|
} |
1522 |
|
|
1523 |
|
} |
1524 |
+ |
|
1525 |
+ |
|
1526 |
+ |
|
1527 |
+ |
|
1528 |
+ |
|
1529 |
+ |
|