bugfix: highlighted differences didn't render correctly
|
@ -90,7 +90,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
||||||
const Color4f &c = j_obj.color;
|
const Color4f &c = j_obj.color;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glMultMatrixd(j_obj.matrix.data());
|
glMultMatrixd(j_obj.matrix.data());
|
||||||
csgmode_e csgmode = j_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : CSGMODE_NORMAL;
|
csgmode_e csgmode = csgmode_e(
|
||||||
|
(highlight ?
|
||||||
|
CSGMODE_HIGHLIGHT :
|
||||||
|
(background ? CSGMODE_BACKGROUND : CSGMODE_NORMAL)) |
|
||||||
|
(j_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : 0));
|
||||||
|
|
||||||
ColorMode colormode = COLORMODE_NONE;
|
ColorMode colormode = COLORMODE_NONE;
|
||||||
if (background) {
|
if (background) {
|
||||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||||
|
@ -99,11 +104,9 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_BACKGROUND;
|
colormode = COLORMODE_BACKGROUND;
|
||||||
}
|
}
|
||||||
csgmode = csgmode_e(csgmode + 10);
|
|
||||||
} else if (j_obj.type == CSGTerm::TYPE_DIFFERENCE) {
|
} else if (j_obj.type == CSGTerm::TYPE_DIFFERENCE) {
|
||||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||||
colormode = COLORMODE_HIGHLIGHT;
|
colormode = COLORMODE_HIGHLIGHT;
|
||||||
csgmode = csgmode_e(csgmode + 20);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_CUTOUT;
|
colormode = COLORMODE_CUTOUT;
|
||||||
|
@ -111,7 +114,6 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
||||||
} else {
|
} else {
|
||||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||||
colormode = COLORMODE_HIGHLIGHT;
|
colormode = COLORMODE_HIGHLIGHT;
|
||||||
csgmode = csgmode_e(csgmode + 20);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_MATERIAL;
|
colormode = COLORMODE_MATERIAL;
|
||||||
|
@ -139,9 +141,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
||||||
|
|
||||||
prim->geom = i_obj.geom;
|
prim->geom = i_obj.geom;
|
||||||
prim->m = i_obj.matrix;
|
prim->m = i_obj.matrix;
|
||||||
prim->csgmode = i_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : CSGMODE_NORMAL;
|
prim->csgmode = csgmode_e(
|
||||||
if (highlight) prim->csgmode = csgmode_e(prim->csgmode + 20);
|
(highlight ?
|
||||||
else if (background) prim->csgmode = csgmode_e(prim->csgmode + 10);
|
CSGMODE_HIGHLIGHT :
|
||||||
|
(background ? CSGMODE_BACKGROUND : CSGMODE_NORMAL)) |
|
||||||
|
(i_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : 0));
|
||||||
|
|
||||||
primitives.push_back(prim);
|
primitives.push_back(prim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,15 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
||||||
const Color4f &c = obj.color;
|
const Color4f &c = obj.color;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glMultMatrixd(m.data());
|
glMultMatrixd(m.data());
|
||||||
csgmode_e csgmode = obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : CSGMODE_NORMAL;
|
csgmode_e csgmode = csgmode_e(
|
||||||
|
(highlight ?
|
||||||
|
CSGMODE_HIGHLIGHT :
|
||||||
|
(background ? CSGMODE_BACKGROUND : CSGMODE_NORMAL)) |
|
||||||
|
(obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : 0));
|
||||||
ColorMode colormode = COLORMODE_NONE;
|
ColorMode colormode = COLORMODE_NONE;
|
||||||
ColorMode edge_colormode = COLORMODE_NONE;
|
ColorMode edge_colormode = COLORMODE_NONE;
|
||||||
|
|
||||||
if (highlight) {
|
if (highlight) {
|
||||||
csgmode = csgmode_e(csgmode + 20);
|
|
||||||
colormode = COLORMODE_HIGHLIGHT;
|
colormode = COLORMODE_HIGHLIGHT;
|
||||||
edge_colormode = COLORMODE_HIGHLIGHT_EDGES;
|
edge_colormode = COLORMODE_HIGHLIGHT_EDGES;
|
||||||
} else if (background) {
|
} else if (background) {
|
||||||
|
@ -89,16 +92,11 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_BACKGROUND;
|
colormode = COLORMODE_BACKGROUND;
|
||||||
}
|
}
|
||||||
csgmode = csgmode_e(csgmode + 10);
|
|
||||||
edge_colormode = COLORMODE_BACKGROUND_EDGES;
|
edge_colormode = COLORMODE_BACKGROUND_EDGES;
|
||||||
} else if (fberror) {
|
} else if (fberror) {
|
||||||
if (highlight) csgmode = csgmode_e(csgmode + 20);
|
|
||||||
else if (background) csgmode = csgmode_e(csgmode + 10);
|
|
||||||
else csgmode = csgmode_e(csgmode);
|
|
||||||
} else if (obj.type == CSGTerm::TYPE_DIFFERENCE) {
|
} else if (obj.type == CSGTerm::TYPE_DIFFERENCE) {
|
||||||
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||||
colormode = COLORMODE_HIGHLIGHT;
|
colormode = COLORMODE_HIGHLIGHT;
|
||||||
csgmode = csgmode_e(csgmode + 20);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_CUTOUT;
|
colormode = COLORMODE_CUTOUT;
|
||||||
|
@ -107,7 +105,6 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
||||||
} else {
|
} else {
|
||||||
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||||
colormode = COLORMODE_HIGHLIGHT;
|
colormode = COLORMODE_HIGHLIGHT;
|
||||||
csgmode = csgmode_e(csgmode + 20);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colormode = COLORMODE_MATERIAL;
|
colormode = COLORMODE_MATERIAL;
|
||||||
|
|
|
@ -240,7 +240,7 @@ void PolySet::render_surface(Renderer::csgmode_e csgmode, const Transform3d &m,
|
||||||
#endif /* ENABLE_OPENCSG */
|
#endif /* ENABLE_OPENCSG */
|
||||||
if (this->dim == 2) {
|
if (this->dim == 2) {
|
||||||
// Render 2D objects 1mm thick, but differences slightly larger
|
// Render 2D objects 1mm thick, but differences slightly larger
|
||||||
double zbase = 1 + (csgmode & CSGMODE_DIFFERENCE_FLAG) * 0.1;
|
double zbase = 1 + ((csgmode & CSGMODE_DIFFERENCE_FLAG) ? 0.1 : 0);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
// Render top+bottom
|
// Render top+bottom
|
||||||
|
@ -369,7 +369,7 @@ void PolySet::render_edges(Renderer::csgmode_e csgmode) const
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Render 2D objects 1mm thick, but differences slightly larger
|
// Render 2D objects 1mm thick, but differences slightly larger
|
||||||
double zbase = 1 + (csgmode & CSGMODE_DIFFERENCE_FLAG) * 0.1;
|
double zbase = 1 + ((csgmode & CSGMODE_DIFFERENCE_FLAG) ? 0.1 : 0);
|
||||||
|
|
||||||
BOOST_FOREACH(const Outline2d &o, polygon.outlines()) {
|
BOOST_FOREACH(const Outline2d &o, polygon.outlines()) {
|
||||||
// Render top+bottom outlines
|
// Render top+bottom outlines
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
difference() {
|
||||||
|
square(10, center=true);
|
||||||
|
#circle(3);
|
||||||
|
}
|
||||||
|
#if (true) square([11,12]);
|
||||||
|
|
||||||
|
#translate([0,-12]) difference() {
|
||||||
|
square(10, center = true);
|
||||||
|
square(5, center = true);
|
||||||
|
}
|
After Width: | Height: | Size: 6.0 KiB |
|
@ -0,0 +1,15 @@
|
||||||
|
group() {
|
||||||
|
difference() {
|
||||||
|
square(size = [10, 10], center = true);
|
||||||
|
# circle($fn = 0, $fa = 12, $fs = 2, r = 3);
|
||||||
|
}
|
||||||
|
# group() {
|
||||||
|
square(size = [11, 12], center = false);
|
||||||
|
}
|
||||||
|
# multmatrix([[1, 0, 0, 0], [0, 1, 0, -12], [0, 0, 1, 0], [0, 0, 0, 1]]) {
|
||||||
|
difference() {
|
||||||
|
square(size = [10, 10], center = true);
|
||||||
|
square(size = [5, 5], center = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.7 KiB |