summaryrefslogtreecommitdiff
path: root/src/OpenCSGRenderer.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-11 05:33:18 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-11 05:33:18 (GMT)
commitc0641d6916775309d64944ca121cc736f0c8d7a1 (patch)
tree801e0b5d67d13ff4773c5906c9cb68d271a2be02 /src/OpenCSGRenderer.cc
parent09cc0496f7ce61e2bcbce80e067e0fac8054599a (diff)
Reenabled PolySet caching. Pass shared_ptrs to polysets around to better manage memory
Diffstat (limited to 'src/OpenCSGRenderer.cc')
-rw-r--r--src/OpenCSGRenderer.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/OpenCSGRenderer.cc b/src/OpenCSGRenderer.cc
index a16d920..4a86c5c 100644
--- a/src/OpenCSGRenderer.cc
+++ b/src/OpenCSGRenderer.cc
@@ -28,6 +28,7 @@
#include "OpenCSGRenderer.h"
#include "polyset.h"
#include "csgterm.h"
+#include "stl-utils.h"
#ifdef ENABLE_OPENCSG
# include <opencsg.h>
#endif
@@ -37,13 +38,13 @@ class OpenCSGPrim : public OpenCSG::Primitive
public:
OpenCSGPrim(OpenCSG::Operation operation, unsigned int convexity) :
OpenCSG::Primitive(operation, convexity) { }
- PolySet *p;
+ shared_ptr<PolySet> ps;
double *m;
int csgmode;
virtual void render() {
glPushMatrix();
glMultMatrixd(m);
- p->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
+ ps->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
glPopMatrix();
}
};
@@ -120,11 +121,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
OpenCSGPrim *prim = new OpenCSGPrim(chain->types[i] == CSGTerm::TYPE_DIFFERENCE ?
OpenCSG::Subtraction : OpenCSG::Intersection, chain->polysets[i]->convexity);
- prim->p = chain->polysets[i];
+ prim->ps = chain->polysets[i];
prim->m = chain->matrices[i];
prim->csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL;
if (highlight) prim->csgmode += 20;
else if (background) prim->csgmode += 10;
primitives.push_back(prim);
}
+ std::for_each(primitives.begin(), primitives.end(), del_fun<OpenCSG::Primitive>());
}
contact: Jan Huwald // Impressum