bugfix: highlighted differences didn't render correctly
|
@ -90,7 +90,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
|||
const Color4f &c = j_obj.color;
|
||||
glPushMatrix();
|
||||
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;
|
||||
if (background) {
|
||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||
|
@ -99,11 +104,9 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
|||
else {
|
||||
colormode = COLORMODE_BACKGROUND;
|
||||
}
|
||||
csgmode = csgmode_e(csgmode + 10);
|
||||
} else if (j_obj.type == CSGTerm::TYPE_DIFFERENCE) {
|
||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||
colormode = COLORMODE_HIGHLIGHT;
|
||||
csgmode = csgmode_e(csgmode + 20);
|
||||
}
|
||||
else {
|
||||
colormode = COLORMODE_CUTOUT;
|
||||
|
@ -111,7 +114,6 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
|||
} else {
|
||||
if (j_obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||
colormode = COLORMODE_HIGHLIGHT;
|
||||
csgmode = csgmode_e(csgmode + 20);
|
||||
}
|
||||
else {
|
||||
colormode = COLORMODE_MATERIAL;
|
||||
|
@ -139,9 +141,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
|
|||
|
||||
prim->geom = i_obj.geom;
|
||||
prim->m = i_obj.matrix;
|
||||
prim->csgmode = i_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : CSGMODE_NORMAL;
|
||||
if (highlight) prim->csgmode = csgmode_e(prim->csgmode + 20);
|
||||
else if (background) prim->csgmode = csgmode_e(prim->csgmode + 10);
|
||||
prim->csgmode = csgmode_e(
|
||||
(highlight ?
|
||||
CSGMODE_HIGHLIGHT :
|
||||
(background ? CSGMODE_BACKGROUND : CSGMODE_NORMAL)) |
|
||||
(i_obj.type == CSGTerm::TYPE_DIFFERENCE ? CSGMODE_DIFFERENCE : 0));
|
||||
|
||||
primitives.push_back(prim);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,12 +74,15 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
|||
const Color4f &c = obj.color;
|
||||
glPushMatrix();
|
||||
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 edge_colormode = COLORMODE_NONE;
|
||||
|
||||
if (highlight) {
|
||||
csgmode = csgmode_e(csgmode + 20);
|
||||
colormode = COLORMODE_HIGHLIGHT;
|
||||
edge_colormode = COLORMODE_HIGHLIGHT_EDGES;
|
||||
} else if (background) {
|
||||
|
@ -89,16 +92,11 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
|||
else {
|
||||
colormode = COLORMODE_BACKGROUND;
|
||||
}
|
||||
csgmode = csgmode_e(csgmode + 10);
|
||||
edge_colormode = COLORMODE_BACKGROUND_EDGES;
|
||||
} 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) {
|
||||
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||
colormode = COLORMODE_HIGHLIGHT;
|
||||
csgmode = csgmode_e(csgmode + 20);
|
||||
}
|
||||
else {
|
||||
colormode = COLORMODE_CUTOUT;
|
||||
|
@ -107,7 +105,6 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
|
|||
} else {
|
||||
if (obj.flag & CSGTerm::FLAG_HIGHLIGHT) {
|
||||
colormode = COLORMODE_HIGHLIGHT;
|
||||
csgmode = csgmode_e(csgmode + 20);
|
||||
}
|
||||
else {
|
||||
colormode = COLORMODE_MATERIAL;
|
||||
|
|
|
@ -240,7 +240,7 @@ void PolySet::render_surface(Renderer::csgmode_e csgmode, const Transform3d &m,
|
|||
#endif /* ENABLE_OPENCSG */
|
||||
if (this->dim == 2) {
|
||||
// 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);
|
||||
|
||||
// Render top+bottom
|
||||
|
@ -369,7 +369,7 @@ void PolySet::render_edges(Renderer::csgmode_e csgmode) const
|
|||
}
|
||||
else {
|
||||
// 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()) {
|
||||
// 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 |