Final tweaks of CSGTerm refactoring

This commit is contained in:
Marius Kintel 2015-12-19 23:26:29 -05:00
parent f3590c648e
commit 3f7b6b3aeb
16 changed files with 20 additions and 43 deletions

View file

@ -79,6 +79,7 @@ void CSGTermEvaluator::applyToChildren(State &state, const AbstractNode &node, O
t = CSGOperation::createCSGNode(op, t1, t2);
t->setBackground(true);
}
// Background objects are simply moved to background_terms
else if (t2->isBackground()) {
t = t1;
this->background_terms.push_back(t2);
@ -91,7 +92,6 @@ void CSGTermEvaluator::applyToChildren(State &state, const AbstractNode &node, O
t = CSGOperation::createCSGNode(op, t1, t2);
}
// Handle highlight
#if 1
switch (op) {
case OPENSCAD_DIFFERENCE:
if (t != t1 && t1->isHighlight()) {
@ -115,46 +115,27 @@ void CSGTermEvaluator::applyToChildren(State &state, const AbstractNode &node, O
break;
case OPENSCAD_UNION:
if (t != t1 && t != t2 &&
t1->isHighlight() && t2->isHighlight()) {
t1->isHighlight() && t2->isHighlight()) {
t->setHighlight(true);
}
// FIXME: How to deal with differences: (#A + B) - C
else if (t != t1 && t1->isHighlight()) {
this->highlight_terms.push_back(t1);
t = t2;
}
else if (t != t2 && t2->isHighlight()) {
this->highlight_terms.push_back(t2);
t = t1;
}
break;
}
#endif
t1 = t;
}
}
#if 0
if (t1 && ((t1->isHighlight()) || node.modinst->isHighlight())) {
t1->setHighlight(true);
if (!state.isHighlight()) {
this->highlight_terms.push_back(t1);
state.setHighlight(true);
// FIXME: If we remove the positive part of a difference, we cannot properly render the negative
// t1.reset();
}
if (t1) {
if (node.modinst->isBackground()) t1->setBackground(true);
if (node.modinst->isHighlight()) t1->setHighlight(true);
}
if (t1 && node.modinst->isBackground()) {
// t1->flag = CSGNode::FLAG_BACKGROUND;
this->background_terms.push_back(t1);
state.setBackground(true);
t1.reset();
}
#endif
if (t1) {
if (node.modinst->isBackground()) t1->setBackground(true);
if (node.modinst->isHighlight()) t1->setHighlight(true);
}
this->stored_term[node.index()] = t1;
this->stored_term[node.index()] = t1;
}
Response CSGTermEvaluator::visit(State &state, const AbstractNode &node)

View file

@ -124,13 +124,11 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
colormode = COLORMODE_MATERIAL;
}
if (highlight_mode || !(parent_obj.flags & CSGNode::FLAG_HIGHLIGHT) || !(csgobj.flags & CSGNode::FLAG_HIGHLIGHT) ) {
setColor(colormode, c.data(), shaderinfo);
glPushMatrix();
glMultMatrixd(csgobj.matrix.data());
render_surface(csgobj.geom, csgmode, csgobj.matrix, shaderinfo);
glPopMatrix();
}
setColor(colormode, c.data(), shaderinfo);
glPushMatrix();
glMultMatrixd(csgobj.matrix.data());
render_surface(csgobj.geom, csgmode, csgobj.matrix, shaderinfo);
glPopMatrix();
}
BOOST_FOREACH(const CSGChainObject &csgobj, product.subtractions) {
const Color4f &c = csgobj.color;
@ -148,13 +146,11 @@ void OpenCSGRenderer::renderCSGProducts(const CSGProducts &products, GLint *shad
colormode = COLORMODE_CUTOUT;
}
if (highlight_mode || !(parent_obj.flags & CSGNode::FLAG_HIGHLIGHT) || !(csgobj.flags & CSGNode::FLAG_HIGHLIGHT) ) {
setColor(colormode, c.data(), shaderinfo);
glPushMatrix();
glMultMatrixd(csgobj.matrix.data());
render_surface(csgobj.geom, csgmode, csgobj.matrix, shaderinfo);
glPopMatrix();
}
setColor(colormode, c.data(), shaderinfo);
glPushMatrix();
glMultMatrixd(csgobj.matrix.data());
render_surface(csgobj.geom, csgmode, csgobj.matrix, shaderinfo);
glPopMatrix();
}
if (shaderinfo) glUseProgram(0);
@ -168,7 +164,7 @@ BoundingBox OpenCSGRenderer::getBoundingBox() const
{
BoundingBox bbox;
if (this->root_products) bbox = this->root_products->getBoundingBox();
// if (this->highlights_products) bbox.extend(this->highlights_products->getBoundingBox());
if (this->highlights_products) bbox.extend(this->highlights_products->getBoundingBox());
if (this->background_products) bbox.extend(this->background_products->getBoundingBox());

View file

@ -137,7 +137,7 @@ BoundingBox ThrownTogetherRenderer::getBoundingBox() const
{
BoundingBox bbox;
if (this->root_products) bbox = this->root_products->getBoundingBox();
// if (this->highlight_products) bbox.extend(this->highlight_products->getBoundingBox());
if (this->highlight_products) bbox.extend(this->highlight_products->getBoundingBox());
// if (this->background_products) bbox.extend(this->background_products->getBoundingBox());
return bbox;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB