Skip to content

Commit

Permalink
Relocate dl_add_path next to its use
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Dec 2, 2024
1 parent 483dcab commit 681303b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 131 deletions.
129 changes: 0 additions & 129 deletions src/libged/display_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,135 +680,6 @@ solid_append_vlist(struct bv_scene_obj *sp, struct bv_vlist *vlist)
BU_LIST_APPEND_LIST(&(sp->s_vlist), &(vlist->l));
}


void
dl_add_path(int dashflag, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, unsigned char *wireframe_color_override, struct _ged_client_data *dgcdp)
{
if (!dgcdp || !dgcdp->v)
return;

struct bv_scene_obj *sp = bv_obj_get(dgcdp->v, BV_DB_OBJS);
if (!sp)
return;

struct ged_bv_data *bdata = (sp->s_u_data) ? (struct ged_bv_data *)sp->s_u_data : NULL;
if (!bdata) {
BU_GET(bdata, struct ged_bv_data);
db_full_path_init(&bdata->s_fullpath);
sp->s_u_data = (void *)bdata;
} else {
bdata->s_fullpath.fp_len = 0;
}
if (!sp->s_u_data)
return;

solid_append_vlist(sp, (struct bv_vlist *)vhead);

bv_scene_obj_bound(sp, dgcdp->v);

db_dup_full_path(&bdata->s_fullpath, pathp);

sp->s_flag = DOWN;
sp->s_iflag = DOWN;
sp->s_soldash = dashflag;
sp->s_old.s_Eflag = 0;

if (tsp) {
sp->s_old.s_regionid = tsp->ts_regionid;
}

solid_set_color_info(sp, wireframe_color_override, tsp);

sp->s_dlist = 0;
sp->s_os->transparency = dgcdp->vs.transparency;
sp->s_os->s_dmode = dgcdp->vs.s_dmode;

/* append solid to display list */
bu_semaphore_acquire(RT_SEM_MODEL);
BU_LIST_APPEND(dgcdp->gdlp->dl_head_scene_obj.back, &sp->l);
bu_semaphore_release(RT_SEM_MODEL);

ged_create_vlist_solid_cb(dgcdp->gedp, sp);

}


static fastf_t
draw_solid_wireframe(struct bv_scene_obj *sp, struct bview *gvp, struct db_i *dbip,
const struct bn_tol *tol, const struct bg_tess_tol *ttol)
{
int ret;
struct bu_list vhead;
struct rt_db_internal dbintern;
struct rt_db_internal *ip = &dbintern;

BU_LIST_INIT(&vhead);
if (!sp->s_u_data)
return -1;
struct ged_bv_data *bdata = (struct ged_bv_data *)sp->s_u_data;

ret = rt_db_get_internal(ip, DB_FULL_PATH_CUR_DIR(&bdata->s_fullpath),
dbip, sp->s_mat, &rt_uniresource);

if (ret < 0) {
return -1;
}

if (gvp && gvp->gv_s->adaptive_plot_csg && ip->idb_meth->ft_adaptive_plot) {
ret = ip->idb_meth->ft_adaptive_plot(&vhead, ip, tol, gvp, sp->s_size);
} else if (ip->idb_meth->ft_plot) {
ret = ip->idb_meth->ft_plot(&vhead, ip, ttol, tol, gvp);
}

rt_db_free_internal(ip);

if (ret < 0) {
if (DB_FULL_PATH_CUR_DIR(&bdata->s_fullpath))
bu_log("%s: plot failure\n", DB_FULL_PATH_CUR_DIR(&bdata->s_fullpath)->d_namep);

return -1;
}

/* add plot to solid */
solid_append_vlist(sp, (struct bv_vlist *)&vhead);

return 0;
}


int
redraw_solid(struct bv_scene_obj *sp, struct db_i *dbip, struct db_tree_state *tsp, struct bview *gvp)
{
if (sp->s_os->s_dmode == _GED_WIREFRAME) {
/* replot wireframe */
if (BU_LIST_NON_EMPTY(&sp->s_vlist)) {
BV_FREE_VLIST(&RTG.rtg_vlfree, &sp->s_vlist);
}
return draw_solid_wireframe(sp, gvp, dbip, tsp->ts_tol, tsp->ts_ttol);
}
return 0;
}


int
dl_redraw(struct display_list *gdlp, struct ged *gedp, int skip_subtractions)
{
struct db_i *dbip = gedp->dbip;
struct rt_wdb *wdbp = wdb_dbopen(gedp->dbip, RT_WDB_TYPE_DB_DEFAULT);
struct db_tree_state *tsp = &wdbp->wdb_initial_tree_state;
struct bview *gvp = gedp->ged_gvp;
int ret = 0;
struct bv_scene_obj *sp;
for (BU_LIST_FOR(sp, bv_scene_obj, &gdlp->dl_head_scene_obj)) {
if (!skip_subtractions || (skip_subtractions && !sp->s_soldash)) {
ret += redraw_solid(sp, dbip, tsp, gvp);
}
}
ged_create_vlist_display_list_cb(gedp, gdlp);
return ret;
}


static void
solid_copy_vlist(struct db_i *UNUSED(dbip), struct bv_scene_obj *sp, struct bv_vlist *vlist)
{
Expand Down
2 changes: 0 additions & 2 deletions src/libged/ged_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ GED_EXPORT extern void _dl_eraseAllPathsFromDisplay(struct ged *gedp, const char
extern void _dl_freeDisplayListItem(struct ged *gedp, struct display_list *gdlp);
GED_EXPORT extern int dl_bounding_sph(struct bu_list *hdlp, vect_t *min, vect_t *max, int pflag);

GED_EXPORT extern void dl_add_path(int dashflag, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, unsigned char *wireframe_color_override, struct _ged_client_data *dgcdp);

GED_EXPORT extern void color_soltab(struct bv_scene_obj *sp);
GED_EXPORT extern void solid_set_color_info(struct bv_scene_obj *sp, unsigned char *wireframe_color_override, struct db_tree_state *tsp);

Expand Down
59 changes: 59 additions & 0 deletions src/libged/ged_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,65 @@ _ged_do_list(struct ged *gedp, struct directory *dp, int verbose)
}
}



void
dl_add_path(int dashflag, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, unsigned char *wireframe_color_override, struct _ged_client_data *dgcdp)
{
if (!dgcdp || !dgcdp->v)
return;

struct bv_scene_obj *sp = bv_obj_get(dgcdp->v, BV_DB_OBJS);
if (!sp)
return;

struct ged_bv_data *bdata = (sp->s_u_data) ? (struct ged_bv_data *)sp->s_u_data : NULL;
if (!bdata) {
BU_GET(bdata, struct ged_bv_data);
db_full_path_init(&bdata->s_fullpath);
sp->s_u_data = (void *)bdata;
} else {
bdata->s_fullpath.fp_len = 0;
}
if (!sp->s_u_data)
return;


if (BU_LIST_IS_EMPTY(&(sp->s_vlist)))
sp->s_vlen = 0;

struct bv_vlist *bvv = (struct bv_vlist *)vhead;
sp->s_vlen += bv_vlist_cmd_cnt(bvv);
BU_LIST_APPEND_LIST(&(sp->s_vlist), &(bvv->l));

bv_scene_obj_bound(sp, dgcdp->v);

db_dup_full_path(&bdata->s_fullpath, pathp);

sp->s_flag = DOWN;
sp->s_iflag = DOWN;
sp->s_soldash = dashflag;
sp->s_old.s_Eflag = 0;

if (tsp) {
sp->s_old.s_regionid = tsp->ts_regionid;
}

solid_set_color_info(sp, wireframe_color_override, tsp);

sp->s_dlist = 0;
sp->s_os->transparency = dgcdp->vs.transparency;
sp->s_os->s_dmode = dgcdp->vs.s_dmode;

/* append solid to display list */
bu_semaphore_acquire(RT_SEM_MODEL);
BU_LIST_APPEND(dgcdp->gdlp->dl_head_scene_obj.back, &sp->l);
bu_semaphore_release(RT_SEM_MODEL);

ged_create_vlist_solid_cb(dgcdp->gedp, sp);

}

/**
* Once the vlist has been created, perform the common tasks
* in handling the drawn solid.
Expand Down

0 comments on commit 681303b

Please sign in to comment.