Revision: 53477
http://brlcad.svn.sourceforge.net/brlcad/?rev=53477&view=rev
Author: n_reed
Date: 2012-11-06 21:28:45 +0000 (Tue, 06 Nov 2012)
Log Message:
-----------
update solid's vlist length at the same time as its vlist rather than waiting
for it to be a side-effect of the bounding routine
Modified Paths:
--------------
brlcad/trunk/src/libged/draw.c
Modified: brlcad/trunk/src/libged/draw.c
===================================================================
--- brlcad/trunk/src/libged/draw.c 2012-11-06 18:37:27 UTC (rev 53476)
+++ brlcad/trunk/src/libged/draw.c 2012-11-06 21:28:45 UTC (rev 53477)
@@ -159,10 +159,46 @@
return curtree;
}
+/* returns the sum total number of commands in all nodes of the vlist */
+static int
+vlist_total_commands(struct bn_vlist *vlist)
+{
+ int num_commands;
+ struct bn_vlist *vp;
+ if (UNLIKELY(vlist == NULL)) {
+ return 0;
+ }
+
+ num_commands = 0;
+ for (BU_LIST_FOR(vp, bn_vlist, &(vlist->l))) {
+ num_commands += vp->nused;
+ }
+
+ return num_commands;
+}
+
+static void
+solid_append_vlist(struct solid *sp, struct bn_vlist *vlist)
+{
+ if (BU_LIST_IS_EMPTY(&(sp->s_vlist))) {
+ sp->s_vlen = 0;
+ }
+
+ BU_LIST_APPEND_LIST(&(sp->s_vlist), &(vlist->l));
+ sp->s_vlen += vlist_total_commands(vlist);
+}
+
+static void
+solid_copy_vlist(struct solid *sp, struct bn_vlist *vlist)
+{
+ BU_LIST_INIT(&(sp->s_vlist));
+ rt_vlist_copy(&(sp->s_vlist), (struct bu_list *)vlist);
+ sp->s_vlen = vlist_total_commands((struct bn_vlist *)(&(sp->s_vlist)));
+}
+
/**
- * Compute the min, max, and center points of the solid. Also finds
- * s_vlen.
+ * Compute the min, max, and center points of the solid.
*
* XXX Should split out a separate bn_vlist_rpp() routine, for
* librt/vlist.c
@@ -176,13 +212,14 @@
xmax = ymax = zmax = -INFINITY;
xmin = ymin = zmin = INFINITY;
- sp->s_vlen = 0;
+
for (BU_LIST_FOR(vp, bn_vlist, &(sp->s_vlist))) {
- int j;
+ int i;
int nused = vp->nused;
int *cmd = vp->cmd;
point_t *pt = vp->pt;
- for (j = 0; j < nused; j++, cmd++, pt++) {
+
+ for (i = 0; i < nused; i++, cmd++, pt++) {
switch (*cmd) {
case BN_VLIST_POLY_START:
case BN_VLIST_POLY_VERTNORM:
@@ -207,12 +244,9 @@
V_MAX(zmax, (*pt)[Z]);
break;
default:
- {
- bu_vls_printf(gedp->ged_result_str, "unknown vlist op
%d\n", *cmd);
- }
+ bu_vls_printf(gedp->ged_result_str, "unknown vlist op
%d\n", *cmd);
}
}
- sp->s_vlen += nused;
}
sp->s_center[X] = (xmin + xmax) * 0.5;
@@ -295,11 +329,11 @@
sp = existing_sp;
}
+ solid_append_vlist(sp, (struct bn_vlist *)vhead);
/*
* Compute the min, max, and center points.
*/
- BU_LIST_APPEND_LIST(&(sp->s_vlist), vhead);
bound_solid(dgcdp->gedp, sp);
/*
@@ -1082,11 +1116,9 @@
GET_SOLID(sp, &_FreeSolid.l);
if (copy) {
- BU_LIST_INIT(&(sp->s_vlist));
- rt_vlist_copy(&(sp->s_vlist), vhead);
+ solid_copy_vlist(sp, (struct bn_vlist *)vhead);
} else {
- /* For efficiency, just swipe the vlist */
- BU_LIST_APPEND_LIST(&(sp->s_vlist), vhead);
+ solid_append_vlist(sp, (struct bn_vlist *)vhead);
BU_LIST_INIT(vhead);
}
bound_solid(gedp, sp);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits