[brlcad-commits] SF.net SVN: brlcad:[35462] brlcad/trunk
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <n_...@us...> - 2009-08-04 03:01:40
|
Revision: 35462 http://brlcad.svn.sourceforge.net/brlcad/?rev=35462&view=rev Author: n_reed Date: 2009-08-04 03:01:31 +0000 (Tue, 04 Aug 2009) Log Message: ----------- updating mged's display while dm-rtgl does ray tracing; removing tgc logs when using dm-rtgl Modified Paths: -------------- brlcad/trunk/include/dm-rtgl.h brlcad/trunk/src/libdm/dm-rtgl.c brlcad/trunk/src/librt/Makefile.am brlcad/trunk/src/librt/primitives/tgc/tgc.c brlcad/trunk/src/mged/dozoom.c brlcad/trunk/src/mged/mged.c Modified: brlcad/trunk/include/dm-rtgl.h =================================================================== --- brlcad/trunk/include/dm-rtgl.h 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/include/dm-rtgl.h 2009-08-04 03:01:31 UTC (rev 35462) @@ -41,8 +41,19 @@ #define Rtgl_MV_O(_m) offsetof(struct modifiable_rtgl_vars, _m) +#define DM_PRIV_VARS (dmp->dm_vars.priv_vars) +#define RTGL_GEDP ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.gedp +#define RTGL_LASTJOBS ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.lastJobs +#define RTGL_BLOCKING ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.blocking +#define RTGL_JOBSDONE ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.jobsDone +#define RTGL_DOJOBS ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.doJobs + struct modifiable_rtgl_vars { struct ged *gedp; /* used to set up ray tracing */ + time_t lastJobs; + int blocking; + int jobsDone; + int doJobs; int cueing_on; int zclipping_on; int zbuffer_on; @@ -73,6 +84,12 @@ extern void rtgl_fogHint(); +struct jobList { + struct bu_list l; + point_t pt; + vect_t dir; +}; + #define PT_ARRAY_SIZE 999 struct ptInfoList { Modified: brlcad/trunk/src/libdm/dm-rtgl.c =================================================================== --- brlcad/trunk/src/libdm/dm-rtgl.c 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/src/libdm/dm-rtgl.c 2009-08-04 03:01:31 UTC (rev 35462) @@ -60,7 +60,6 @@ #include "dm_xvars.h" #include "solid.h" - #define VIEWFACTOR (1.0/(*dmp->dm_vp)) #define VIEWSIZE (2.0*(*dmp->dm_vp)) @@ -181,6 +180,8 @@ int controlClip = 1; +int calls; + /* ray trace vars */ struct application app; struct rt_i *rtip; @@ -292,6 +293,8 @@ if (bu_vls_strlen(&init_proc_vls) == 0) bu_vls_strcpy(&init_proc_vls, "bind_dm"); + calls = 1; + /* initialize dm specific variables */ ((struct dm_xvars *)dmp->dm_vars.pub_vars)->devmotionnotify = LASTEvent; ((struct dm_xvars *)dmp->dm_vars.pub_vars)->devbuttonpress = LASTEvent; @@ -300,6 +303,10 @@ /* initialize modifiable variables */ ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.gedp = GED_NULL; + ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.blocking = 0; + ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.lastJobs = 0; + ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.jobsDone = 1; + ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.doJobs = 0; ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.rgb = 1; ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.doublebuffer = 1; ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.fastfog = 1; @@ -913,7 +920,7 @@ fastf_t clip, scale = 1; /* get ged struct */ - struct ged *gedp = ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.gedp; + struct ged *gedp = RTGL_GEDP; if (gedp != GED_NULL) { @@ -1236,6 +1243,8 @@ glEnable(GL_LIGHTING); } +struct jobList jobs; +struct jobList *currJob; /* shoot an even grid of parallel rays in a principle direction */ void shootGrid(vect_t min, vect_t max, int pixels, int viewSize, int uAxis, int vAxis, int iAxis) { int i, j; @@ -1253,8 +1262,6 @@ vDivs /= 2; #endif - bu_log("firing %d x %d grid", uDivs, vDivs); - fastf_t uWidth = span[uAxis] / uDivs; fastf_t vWidth = span[vAxis] / vDivs; @@ -1280,8 +1287,16 @@ app.a_ray.r_pt[uAxis] = u; app.a_ray.r_pt[vAxis] = v; - /* points are drawn in hit routine */ +#if 0 rt_shootray(&app); +#else + /* make new job */ + BU_GETSTRUCT(currJob, jobList); + BU_LIST_PUSH(&(jobs.l), currJob); + + VMOVE(currJob->pt, app.a_ray.r_pt); + VMOVE(currJob->dir, app.a_ray.r_dir); +#endif } /* reset u */ @@ -1289,10 +1304,37 @@ } } +/* return 1 if all jobs done, 0 if not */ +int shootJobs(void) { + time_t start = time(NULL); + + /* list cannot be empty */ + if (jobs.l.forw != NULL && (struct jobList *)jobs.l.forw != &jobs) { + + while (BU_LIST_WHILE(currJob, jobList, &(jobs.l))) { + VMOVE(app.a_ray.r_pt, currJob->pt); + VMOVE(app.a_ray.r_dir, currJob->dir); + + rt_shootray(&app); + + BU_LIST_DEQUEUE(&(currJob->l)); + bu_free(currJob, "free jobs currJob"); + + if (difftime(time(NULL), start) > (1/50)) + return 0; + + } + + jobs.l.forw = BU_LIST_NULL; + } + + return 1; +} + void drawPoints(fastf_t *view) { glPointSize(2); -#if 1 /* use vertex arrays */ +#if 0 /* use vertex arrays */ glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); #endif @@ -1307,7 +1349,7 @@ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (float *) &(currItem->color)); -#if 0 +#if 1 glBegin(GL_POINTS); for (i = 0; i < numPoints; i++) { index = i + i + i; @@ -1318,7 +1360,8 @@ dot = VDOT(view, normal); - if (0 && dot < 0) { + /* make all normals face front*/ + if (dot < 0) { VREVERSE(normal, normal); } glNormal3d(normal[X], normal[Y], normal[Z]); @@ -1332,6 +1375,7 @@ glDrawArrays(GL_POINTS, 0, numPoints); #endif } + glDisable(GL_LIGHTING); glColor3d(0.0, 1.0, 0.0); glPointSize(1); } @@ -1494,10 +1538,10 @@ } } + vect_t min, max, span, center, view, vect; fastf_t radius; - /* * R T G L _ D R A W V L I S T * @@ -1505,14 +1549,12 @@ HIDDEN int rtgl_drawVList(struct dm *dmp, register struct bn_vlist *vp) { - static int call; - int i, j, new, numVisible, numNew, maxPixels, viewSize; char *currTree, *visibleTrees[RT_MAXARGS]; struct ptInfoList *curr; /* get ged struct */ - struct ged *gedp = ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.gedp; + struct ged *gedp = RTGL_GEDP; if (gedp == GED_NULL) return TCL_ERROR; @@ -1539,7 +1581,7 @@ viewSize = gedp->ged_gvp->gv_size; /* initialize list */ - if (ptInfo.l.forw == BU_LIST_NULL) { + if (calls == 1 || ptInfo.l.forw == BU_LIST_NULL) { /* initialize head */ BU_LIST_INIT(&(ptInfo.l)); ptInfo.used = 0; @@ -1548,12 +1590,10 @@ BU_GETSTRUCT(currItem, ptInfoList); BU_LIST_PUSH(&(ptInfo.l), currItem); currItem->used = 0; - - call = 1; } /* get names of all drawable objects */ - if (call == 1) { + if (0) { numTops = getTops(gedp); for (i = 0; i < numTops; i++) { @@ -1567,9 +1607,13 @@ /* no objects are visible */ if (numVisible == 0) { - /* drop all display points */ + /* drop previous work */ + oldNumTrees = 0; freeInfoList(); + RTGL_JOBSDONE = 1; + RTGL_DOJOBS = 0; + /* reset for dynamic z-clipping */ if (dmp->dm_zbuffer) { startScale = 1; @@ -1602,9 +1646,16 @@ } } + if (RTGL_JOBSDONE) { + RTGL_BLOCKING = 0; + } + /* get points for new trees */ if (numNew > 0) { + /* initialize job list */ + BU_LIST_INIT(&(jobs.l)); + /* set up application */ RT_APPLICATION_INIT(&app); app.a_onehit = 0; @@ -1637,18 +1688,24 @@ randShots(center, radius, 1); #endif - } + /* new jobs to do */ + RTGL_DOJOBS = 1; + RTGL_BLOCKING = 1; + + } /* numNew > 0 */ + vect_t vCenter; VSET(vCenter, 0, 0, 0); aeVect(view, gedp->ged_gvp->gv_aet, vCenter, 1); drawPoints(view); -/* - randShots(center, radius, 0); -*/ - call++; + calls++; + + if (calls > 1 && RTGL_DOJOBS) { + RTGL_JOBSDONE = shootJobs(); + } return TCL_OK; } Modified: brlcad/trunk/src/librt/Makefile.am =================================================================== --- brlcad/trunk/src/librt/Makefile.am 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/src/librt/Makefile.am 2009-08-04 03:01:31 UTC (rev 35462) @@ -4,6 +4,12 @@ librt_nil.la \ librt_xxx.la +if BUILD_RTGL +DM_RTGL_CPPFLAGS = -DDM_RTGL -DIF_RTGL $(GL_CPPFLAGS) +else +DM_RTGL_CPPFLAGS = +endif + BREP_TEST = brep_test BREP_CPPFLAGS = ${SSE} -DOBJ_BREP=1 ${TNT_CPPFLAGS} ${OPENNURBS_CPPFLAGS} BREP_LIBADD = ${OPENNURBS} @@ -19,7 +25,8 @@ AM_CPPFLAGS = \ ${REGEX_CPPFLAGS} \ ${TCL_CPPFLAGS} \ - ${BREP_CPPFLAGS} + ${BREP_CPPFLAGS} \ + ${DM_RTGL_CPPFLAGS} noinst_PROGRAMS = \ comb \ Modified: brlcad/trunk/src/librt/primitives/tgc/tgc.c =================================================================== --- brlcad/trunk/src/librt/primitives/tgc/tgc.c 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/src/librt/primitives/tgc/tgc.c 2009-08-04 03:01:31 UTC (rev 35462) @@ -842,6 +842,7 @@ } if ( npts != 0 && npts != 2 && npts != 4 ) { +#ifndef DM_RTGL /* these are printed in 'mm' regardless of local units */ bu_log("tgc(%s): %d intersects != {0, 2, 4}\n", stp->st_name, npts ); bu_log( "\tray: pt = (%g %g %g), dir = (%g %g %g), units in mm\n", V3ARGS( ap->a_ray.r_pt ), V3ARGS( ap->a_ray.r_dir ) ); @@ -849,6 +850,7 @@ bu_log( "\t%g", k[i]*t_scale ); } bu_log( "\n" ); +#endif return(0); /* No hit */ } @@ -1130,9 +1132,11 @@ k[i] -= cor_proj; if ( npts != 0 && npts != 2 && npts != 4 ) { +#ifndef DM_RTGL bu_log("tgc(%s): %d intersects != {0, 2, 4}\n", stp[ix]->st_name, npts ); RT_TGC_SEG_MISS(segp[ix]); /* No hit */ +#endif continue; } Modified: brlcad/trunk/src/mged/dozoom.c =================================================================== --- brlcad/trunk/src/mged/dozoom.c 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/src/mged/dozoom.c 2009-08-04 03:01:31 UTC (rev 35462) @@ -403,10 +403,26 @@ if (IS_DM_TYPE_RTGL(dmp->dm_type)) { /* dm-rtgl needs database info for ray tracing */ - ((struct rtgl_vars *)dmp->dm_vars.priv_vars)->mvars.gedp = gedp; + RTGL_GEDP = gedp; - DM_DRAW_VLIST(dmp, (struct bn_vlist *)NULL); - + if (!RTGL_JOBSDONE) { + RTGL_BLOCKING = 1; + + /* do jobs if user has been given time to trigger other events */ + if (difftime(time(NULL), RTGL_LASTJOBS) > 2) { + RTGL_DOJOBS = 1; + RTGL_LASTJOBS = time(NULL); + } + } + + /* draw, and possibly do ray tracing */ + DM_DRAW_VLIST(dmp, (struct bn_vlist *)NULL); + + /* force return to this code */ + if (RTGL_BLOCKING) { + dirty = 1; + } + return; } #endif Modified: brlcad/trunk/src/mged/mged.c =================================================================== --- brlcad/trunk/src/mged/mged.c 2009-08-03 23:01:40 UTC (rev 35461) +++ brlcad/trunk/src/mged/mged.c 2009-08-04 03:01:31 UTC (rev 35462) @@ -81,6 +81,10 @@ #include "./cmd.h" #include "brlcad_version.h" +#ifdef DM_RTGL +# include "dm-rtgl.h" +#endif + #ifndef COMMAND_LINE_EDITING # define COMMAND_LINE_EDITING 1 #endif @@ -1940,6 +1944,11 @@ Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); } +#ifdef DM_RTGL + if (DM_PRIV_VARS != NULL && RTGL_BLOCKING) { + non_blocking++; + } +#endif curr_dm_list = save_dm_list; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |